26 #include <Classes.hpp>
27 #include <Controls.hpp>
28 #include <StdCtrls.hpp>
30 #include <Buttons.hpp>
31 #include <ExtCtrls.hpp>
33 #include <Dialogs.hpp>
34 #include <Graphics.hpp>
35 #include <ComCtrls.hpp>
51 #pragma package(smart_init)
64 Graphics::TBitmap* SmallGraphicPtrVal) : SpeedTag(SpeedTagVal), TrackType(TrackTypeVal), GraphicPtr(GraphicPtrVal), SmallGraphicPtr(SmallGraphicPtrVal)
66 for(
int x = 0; x < 4; x++)
77 else if(SpeedTagVal == 77)
81 else if(SpeedTagVal == 78)
85 else if(SpeedTagVal == 79)
89 else if(SpeedTagVal == 96)
93 else if(SpeedTagVal == 129)
97 else if(SpeedTagVal == 130)
101 else if(SpeedTagVal == 131)
105 else if(SpeedTagVal == 145)
109 else if(SpeedTagVal == 146)
118 FixedNamedLocationElement(false)
120 for(
int x = 0; x < 4; x++)
131 AnsiString(VLocInput));
144 if((this->
HLoc == RHElement.
HLoc) && (this->VLoc == RHElement.
VLoc) && (this->SpeedTag == RHElement.
SpeedTag))
158 if((this->
HLoc != RHElement.
HLoc) || (this->VLoc != RHElement.
VLoc) || (this->SpeedTag != RHElement.
SpeedTag))
174 Graphics::TBitmap *GraphicOutput = GraphicPtr;
176 if(LocationName ==
"")
221 GraphicOutput = GraphicPtr;
225 Disp->PlotOutput(34, HLoc * 16, VLoc * 16, GraphicOutput);
227 if((TrackType ==
Simple) && Failed)
239 AnsiString LogString =
"TrkEl:-," + AnsiString(ElementID) +
"," + LocationName +
"," + AnsiString(TrainIDOnElement) +
"," +
240 AnsiString(TrainIDOnBridgeOrFailedPointOrigSpeedLimit01) +
"," + AnsiString(TrainIDOnBridgeOrFailedPointOrigSpeedLimit23) +
",EndTrkEl,";
249 Attribute(0), CallingOnSet(false), Length01(
Utilities->DefaultTrackLength), Length23(-1), SpeedLimit01(
Utilities->DefaultTrackSpeedLimit), SpeedLimit23(-1),
250 TrainIDOnElement(-1), TrainIDOnBridgeOrFailedPointOrigSpeedLimit01(-1), TrainIDOnBridgeOrFailedPointOrigSpeedLimit23(-1), StationEntryStopLinkPos1(-1),
251 StationEntryStopLinkPos2(-1), StationEntryStopLinkPos3(-1), StationEntryStopLinkPos4(-1), SigAspect(FourAspect)
254 for(
int x = 0; x < 4; x++)
270 if(lower.second < higher.second)
274 else if(lower.second > higher.second)
278 else if(lower.second == higher.second)
280 if(lower.first < higher.first)
293 :
TTrackElement(ElementIn), ELink(ELinkIn), ELinkPos(ELinkPosIn), XLink(XLinkIn), XLinkPos(XLinkPosIn), TrackVectorPosition(TrackVectorPositionIn),
294 CheckCount(9), IsARoute(false), AutoSignals(false), PrefDirRoute(false)
298 throw Exception(
"EXNumber failure in TPrefDirElement constructor");
309 AnsiString LogString =
"PthEl:-," + AnsiString(
ELink) +
"," + AnsiString(
ELinkPos) +
"," + AnsiString(
XLink) +
"," + AnsiString(
XLinkPos) +
"," +
337 {2, 4}, {6, 2}, {8, 6}, {4, 8},
338 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
348 else if(
Link[2] == -1)
361 else if(
Link[2] == -1)
370 for(
int x = 0; x < 16; x++)
372 if(((Entry == EXArray[x][0]) && (Exit == EXArray[x][1])) || ((Entry == EXArray[x][1]) && (Exit == EXArray[x][0])))
548 throw Exception(
"Error in EntryExitNumber 4");
643 throw Exception(
"Error in EntryExitNumber 5");
737 throw Exception(
"Error in EntryExitNumber 6");
824 throw Exception(
"Error in EntryExitNumber 10");
913 throw Exception(
"Error in EntryExitNumber 11");
1009 throw Exception(
"Error in EntryExitNumber 7");
1040 throw Exception(
"Error in EntryExitNumber 8");
1051 if((ELink > 0) && (ELink < 10) && (ELink != 5))
1053 if(!AutoSigsFlag && !PrefDirRoute)
1057 else if(!AutoSigsFlag && PrefDirRoute)
1068 throw Exception(
"Error in EntryExitNumber 9");
1165 AnsiString NL =
'\n';
1167 RouteFailMessage =
"Unable to set a route:" + NL + NL +
"it may be unreachable, perhaps because of failed points; " + NL + NL +
1168 "reachable but too far ahead or with too many different directions leading away from the start point - set some points on the route required; " + NL + NL +
1169 "blocked by a train, another route or a changing level crossing; " + NL + NL +
1170 "or invalid - possibly due to a preferred direction mismatch, or a missed signal in a blue route or green route restricted to consecutive signals.";
1177 int InternalLinkCheckArray[9][2] =
1178 {{1, 9}, {4, 6}, {7, 3}, {2, 8}, {0, 0}, {8, 2}, {3, 7}, {6, 4}, {9, 1}};
1183 for(
int x = 0; x < 9; x++)
1185 for(
int y = 0; y < 2; y++)
1192 TopPlatAllowed << 1 << 9 << 10 << 30 << 31 << 60 << 61 << 68 << 69 << 77 << 125 << 126 << 129 << 145;
1194 BotPlatAllowed << 1 << 7 << 8 << 28 << 29 << 60 << 61 << 68 << 69 << 76 << 125 << 126 << 129 << 145;
1195 LeftPlatAllowed << 2 << 12 << 14 << 33 << 35 << 62 << 63 << 70 << 71 << 79 << 127 << 128 << 130 << 146;
1196 RightPlatAllowed << 2 << 11 << 13 << 32 << 34 << 62 << 63 << 70 << 71 << 78 << 127 << 128 << 130 << 146;
1197 NameAllowed << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 18 << 19 << 20 << 21 << 22 << 23 << 24
1198 << 25 << 26 << 27 << 28 << 29 << 30 << 31 << 32 << 33 << 34 << 35 << 36 << 37 << 38 << 39 << 40 << 41 << 42 << 43 << 44 << 45 << 46 << 47
1199 << 60 << 61 << 62 << 63 << 64 << 65 << 66 << 67 << 68 << 69 << 70 << 71 << 72 << 73 << 74 << 75 << 80 << 81 << 82 << 83 << 84 << 85 << 86
1200 << 87 << 125 << 126 << 127 << 128 << 132 << 133 << 134 << 135 << 136 << 137 << 138 << 139
1201 << 140 << 141 << 142 << 143;
1206 int HVArray[10][2] =
1207 {{0, 0}, {-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {0, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1}};
1209 for(
int x = 0; x < 10; x++)
1211 for(
int y = 0; y < 2; y++)
1220 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1223 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
1224 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
1226 {68, 2,
RailGraphics->
bm68dblyellow}, {69, 2,
RailGraphics->
bm69dblyellow}, {70, 2,
RailGraphics->
bm70dblyellow}, {71, 2,
RailGraphics->
bm71dblyellow},
1227 {72, 2,
RailGraphics->
bm72dblyellow}, {73, 2,
RailGraphics->
bm73dblyellow}, {74, 2,
RailGraphics->
bm74dblyellow}, {75, 2,
RailGraphics->
bm75dblyellow},
1229 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1230 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1233 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1236 for(
int x = 0; x < 40; x++)
1242 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1245 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
1246 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
1248 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
1249 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
1251 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1252 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1255 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1258 for(
int x = 0; x < 40; x++)
1264 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1267 {68, 1,
RailGraphics->
bm68green}, {69, 1,
RailGraphics->
bm69green}, {70, 1,
RailGraphics->
bm70green}, {71, 1,
RailGraphics->
bm71green},
1268 {72, 1,
RailGraphics->
bm72green}, {73, 1,
RailGraphics->
bm73green}, {74, 1,
RailGraphics->
bm74green}, {75, 1,
RailGraphics->
bm75green},
1270 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
1271 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
1273 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1274 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1277 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1280 for(
int x = 0; x < 40; x++)
1306 for(
int x = 0; x < 40; x++)
1312 {{68, 0,
RailGraphics->
FSig68}, {69, 0,
RailGraphics->
FSig69}, {70, 0,
RailGraphics->
FSig70}, {71, 0,
RailGraphics->
FSig71}, {72, 0,
RailGraphics->
FSig72},
1315 for(
int x = 0; x < 8; x++)
1321 {{68, 0,
RailGraphics->
FGSig68}, {69, 0,
RailGraphics->
FGSig69}, {70, 0,
RailGraphics->
FGSig70}, {71, 0,
RailGraphics->
FGSig71}, {72, 0,
RailGraphics->
FGSig72},
1324 for(
int x = 0; x < 8; x++)
1351 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1352 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1353 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {0, 0, 77}, {-1, 0, 78},
1354 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1355 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, -1, 129},
1356 {0, 0, 129}, {0, -1, 145},
1359 for(
int x = 0; x < 25; x++)
1361 for(
int y = 0; y < 3; y++)
1369 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1370 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {0, 0, 76}, {-1, 0, 77},
1371 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1372 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1373 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1374 {0, 0, 129}, {0, 1, 145},
1377 for(
int x = 0; x < 25; x++)
1379 for(
int y = 0; y < 3; y++)
1387 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1388 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1389 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1390 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1391 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 0, 79}, {-1, 0, 130},
1392 {0, 0, 130}, {-1, 0, 146},
1395 for(
int x = 0; x < 25; x++)
1397 for(
int y = 0; y < 3; y++)
1405 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1406 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1407 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1408 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {0, 0, 78}, {-1, 0, 79},
1409 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {1, 0, 130},
1410 {0, 0, 130}, {1, 0, 146},
1413 for(
int x = 0; x < 25; x++)
1415 for(
int y = 0; y < 3; y++)
1423 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1424 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1425 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1426 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1427 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1428 {0, -1, 129}, {1, 0, 130},
1429 {-1, 0, 130}, {0, 1, 145},
1430 {0, -1, 145}, {1, 0, 146},
1433 for(
int x = 0; x < 28; x++)
1435 for(
int y = 0; y < 3; y++)
1453 for(
int x = 0; x < 8; x++)
1455 for(
int y = 0; y < 3; y++)
1473 for(
int x = 0; x < 8; x++)
1475 for(
int y = 0; y < 3; y++)
1493 for(
int x = 0; x < 8; x++)
1495 for(
int y = 0; y < 3; y++)
1513 for(
int x = 0; x < 8; x++)
1515 for(
int y = 0; y < 3; y++)
1523 {1, 0, 131}, {0, -1, 131}, {0, 1, 131}};
1525 for(
int x = 0; x < 4; x++)
1527 for(
int y = 0; y < 3; y++)
1535 0, 1, 2, 5, 6, 3, 4, 9, 10, 7, 8, 13, 14, 11, 12, 15, 16, 17, 19, 18, 22, 23, 20, 21, 26, 27, 24, 25, 30, 31, 28, 29, 34, 35, 32, 33, 38, 39, 36, 37, 42,
1536 43, 40, 41, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 60, 61, 63, 62, 66, 67, 64, 65, 68, 69, 71, 70, 74, 75, 72, 73, 77, 76, 78,
1537 79, 80, 81, 83, 82, 86, 87, 84, 85, 88, 89, 91, 90, 94, 95, 92, 93, 96, 99, 100, 97, 98, 103, 104, 101, 102, 106, 105, 109, 110, 107, 108, 113, 114,
1538 111, 112, 117, 118, 115, 116, 119, 120, 121, 123, 122, 124, 125, 126, 128, 127, 129, 130, 131, 134, 133, 132, 135, 139, 138, 137, 136, 143, 142, 141,
1544 0, 1, 2, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 15, 16, 17, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41,
1545 40, 43, 42, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 61, 60, 62, 63, 65, 64, 67, 66, 69, 68, 70, 71, 73, 72, 75, 74, 76, 77, 79,
1546 78, 81, 80, 82, 83, 85, 84, 87, 86, 89, 88, 90, 91, 93, 92, 95, 94, 96, 98, 97, 100, 99, 102, 101, 104, 103, 106, 105, 108, 107, 110, 109, 112, 111,
1547 114, 113, 116, 115, 118, 117, 119, 120, 124, 122, 123, 121, 126, 125, 127, 128, 129, 130, 131, 132, 135, 134, 133, 137, 136, 139, 138, 142, 143, 140,
1553 0, 2, 1, 4, 6, 3, 5, 14, 12, 13, 11, 7, 9, 8, 10, 15, 16, 17, 19, 18, 25, 27, 24, 26, 21, 23, 20, 22, 35, 33, 34, 32, 28, 30, 29, 31, 41, 43, 40, 42, 37,
1554 39, 36, 38, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 63, 62, 60, 61, 65, 67, 64, 66, 71, 70, 68, 69, 73, 75, 72, 74, 79, 78, 76,
1555 77, 83, 82, 80, 81, 85, 87, 84, 86, 91, 90, 88, 89, 93, 95, 92, 94, 96, 102, 104, 101, 103, 98, 100, 97, 99, 106, 105, 108, 110, 107, 109, 116, 118,
1556 115, 117, 112, 114, 111, 113, 120, 119, 122, 124, 121, 123, 127, 128, 126, 125, 130, 129, 131, 133, 134, 135, 132, 137, 138, 139, 136, 143, 142, 140,
1562 0, 2, 1, 5, 3, 6, 4, 11, 13, 12, 14, 10, 8, 9, 7, 15, 16, 17, 19, 18, 26, 24, 27, 25, 22, 20, 23, 21, 32, 34, 33, 35, 31, 29, 30, 28, 42, 40, 43, 41, 38,
1563 36, 39, 37, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 62, 63, 61, 60, 66, 64, 67, 65, 70, 71, 69, 68, 74, 72, 75, 73, 78, 79, 77,
1564 76, 82, 83, 81, 80, 86, 84, 87, 85, 90, 91, 89, 88, 94, 92, 95, 93, 96, 103, 101, 104, 102, 99, 97, 100, 98, 106, 105, 109, 107, 110, 108, 117, 115,
1565 118, 116, 113, 111, 114, 112, 120, 119, 123, 121, 124, 122, 128, 127, 125, 126, 130, 129, 131, 135, 132, 133, 134, 139, 136, 137, 138, 142, 143, 141,
1587 delete UGMIt->second;
1663 Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
1664 Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
1666 Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
1673 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1674 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1687 {4, 6, -1, -1}, {2, 8, -1, -1}, {6, 8, -1, -1}, {4, 8, -1, -1}, {2, 6, -1, -1}, {2, 4, -1, -1},
1688 {4, 6, 4, 2}, {6, 4, 6, 2}, {4, 6, 4, 8}, {6, 4, 6, 8}, {8, 2, 8, 4}, {8, 2, 8, 6}, {2, 8, 2, 4}, {2, 8, 2, 6},
1690 {4, 6, 2, 8}, {1, 9, 3, 7},
1692 {3, 7, -1, -1}, {1, 9, -1, -1}, {7, 6, -1, -1}, {4, 9, -1, -1}, {1, 6, -1, -1}, {4, 3, -1, -1}, {3, 8, -1, -1}, {1, 8, -1, -1}, {2, 9, -1, -1},
1694 {4, 6, 4, 3}, {6, 4, 6, 1}, {4, 6, 4, 9}, {6, 4, 6, 7}, {8, 2, 8, 1}, {8, 2, 8, 3}, {2, 8, 2, 7}, {2, 8, 2, 9}, {9, 1, 9, 2}, {7, 3, 7, 2}, {3, 7, 3, 8}, {1, 9, 1, 8}, {9, 1, 9, 4}, {7, 3, 7, 6}, {3, 7, 3, 4}, {1, 9, 1, 6},
1697 {1, 9, 2, 8}, {2, 8, 3, 7}, {4, 6, 3, 7}, {1, 9, 4, 6},
1698 {2, 8, 4, 6}, {4, 6, 2, 8}, {3, 7, 1, 9}, {1, 9, 3, 7}, {2, 8, 1, 9}, {2, 8, 3, 7}, {3, 7, 2, 8}, {1, 9, 2, 8}, {4, 6, 3, 7}, {4, 6, 1, 9}, {1, 9, 4, 6}, {3, 7, 4, 6},
1699 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1700 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1},
1701 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1702 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1703 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1705 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1706 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1707 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1708 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1709 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1},
1710 {4, 6, -1, -1}, {2, 8, -1, -1},
1712 {8, 1, 8, 3}, {4, 3, 4, 9}, {2, 9, 2, 7}, {6, 7, 6, 1}, {9, 4, 9, 2}, {7, 2, 7, 6}, {1, 6, 1, 8}, {3, 8, 3, 4},
1714 {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1}, {1, 9, -1, -1},
1716 {4, 6, -1, -1}, {2, 8, -1, -1},
1721 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1722 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1723 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1724 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1727 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1728 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1729 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1731 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1732 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1733 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1735 {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn},
1737 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1738 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1739 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1740 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1741 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1742 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1743 {
Connection,
Signal,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet},
1744 {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet},
1745 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1746 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1747 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1748 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1749 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1751 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1752 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1753 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1754 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1755 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1756 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1757 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1758 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1762 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1763 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1764 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1770 for(
int x = 0; x < 17; x++)
1772 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1774 FixedTrackPiece[17] =
TFixedTrackPiece(17, TrackTypeArray[17], Links[17], Configs[17], 0, 0);
1778 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1784 ExistingGraphicLoaded(false), Width(16), Height(16)
1796 ExistingGraphicLoaded(false), Width(WidthIn), Height(HeightIn)
1834 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalScreenGraphic()");
1838 throw Exception(
"Overlay not 16x16 in TGraphicElement::LoadOriginalScreenGraphic()");
1842 throw Exception(
"Source not set in TGraphicElement::LoadOriginalScreenGraphic()");
1846 throw Exception(
"ExistingGraphicLoaded in TGraphicElement::LoadOriginalScreenGraphic()");
1869 AnsiString(VOffset) +
"," + AnsiString(WidthIn) +
"," + AnsiString(HeightIn));
1872 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalExistingGraphic()");
1876 throw Exception(
"Source not set in TGraphicElement::LoadOriginalExistingGraphic()");
1880 throw Exception(
"ScreenGraphicLoaded in TGraphicElement::LoadOriginalExistingGraphic()");
1914 throw Exception(
"Overlay not loaded in TGraphicElement::PlotOverlay()");
1935 throw Exception(
"Original not loaded in TGraphicElement::PlotOriginal()");
1949 bool TrackPresent =
false;
1963 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1967 TrackPresent =
true;
1972 return(!TrackPresent);
1980 bool TrackPresent =
false;
1989 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1993 TrackPresent =
true;
1999 return(!TrackPresent);
2004 void TTrack::EraseTrackElement(
int Caller,
int HLocInput,
int VLocInput,
int &ErasedTrackVectorPosition,
bool &TrackEraseSuccessfulFlag,
bool InternalChecks)
2007 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2008 TrackEraseSuccessfulFlag =
false;
2013 ErasedTrackVectorPosition = -1;
2014 AnsiString SName =
"", ErrorString;
2016 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
2022 TrackMapKeyPair.first = HLocInput;
2023 TrackMapKeyPair.second = VLocInput;
2024 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
2035 if(ErrorString !=
"")
2037 throw Exception(ErrorString +
" for EraseTrackElement 1");
2061 ErasedTrackVectorPosition = VecPos;
2062 TrackEraseSuccessfulFlag =
true;
2068 unsigned int VecPos;
2069 InactiveTrackMapKeyPair.first = HLocInput;
2070 InactiveTrackMapKeyPair.second = VLocInput;
2075 VecPos = InactiveTrack2MultiMapIterator->second;
2080 if(ErrorString !=
"")
2082 throw Exception(ErrorString +
" for EraseTrackElement 2A");
2092 TrackEraseSuccessfulFlag =
true;
2113 VecPos = InactiveTrack2MultiMapIterator->second;
2118 if(ErrorString !=
"")
2120 throw Exception(ErrorString +
" for EraseTrackElement 2B");
2144 if(TrackEraseSuccessfulFlag)
2160 void TTrack::PlotAndAddTrackElement(
int Caller,
int CurrentTag,
int Aspect,
int HLocInput,
int VLocInput,
bool &TrackLinkingRequiredFlag,
bool InternalChecks,
bool PerformNameSearch)
2167 AnsiString(HLocInput) +
"," + AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2168 bool PlatAllowedFlag =
false;
2170 TrackLinkingRequiredFlag =
false;
2182 LocationNameEntry.first =
"";
2190 TempTrackElement.
HLoc = HLocInput;
2191 TempTrackElement.
VLoc = VLocInput;
2217 else if(Aspect == 1)
2221 else if(Aspect == 2)
2225 else if(Aspect == 3)
2234 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
2237 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
2239 if(InactiveFoundFlag)
2243 NonStationOrLevelCrossingPresent =
true;
2247 NonStationOrLevelCrossingPresent =
true;
2251 PlatformPresent =
true;
2262 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
2270 PlatAllowedFlag =
true;
2274 PlatAllowedFlag =
true;
2278 PlatAllowedFlag =
true;
2282 PlatAllowedFlag =
true;
2286 TrackLinkingRequiredFlag =
true;
2288 if(PerformNameSearch)
2317 if((FoundFlag && (
NameAllowed.Contains(
TrackElementAt(1048, VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
2318 (!FoundFlag && !InactiveFoundFlag))
2321 TrackLinkingRequiredFlag =
true;
2323 if(PerformNameSearch)
2356 TrackLinkingRequiredFlag =
true;
2368 else if(FoundFlag || InactiveFoundFlag)
2381 if(PerformNameSearch)
2390 bool BothPointFillets =
true;
2405 TrackLinkingRequiredFlag =
true;
2407 if(InternalChecks && PerformNameSearch)
2419 bool InternalChecks)
2423 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2424 bool PlatAllowedFlag =
false;
2426 TrackLinkingRequiredFlag =
false;
2429 LocationNameEntry.first =
"";
2435 TempTrackElement.
HLoc = HLocInput;
2436 TempTrackElement.
VLoc = VLocInput;
2437 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
2438 for(
int x = 0; x < 4; x++)
2444 TempTrackElement.
Conn[x] = -1;
2458 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
2460 if(InactiveFoundFlag)
2464 NonStationOrLevelCrossingPresent =
true;
2468 NonStationOrLevelCrossingPresent =
true;
2472 PlatformPresent =
true;
2483 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
2491 PlatAllowedFlag =
true;
2495 PlatAllowedFlag =
true;
2499 PlatAllowedFlag =
true;
2503 PlatAllowedFlag =
true;
2507 TrackLinkingRequiredFlag =
true;
2538 if((FoundFlag && (
NameAllowed.Contains(
TrackElementAt(1055, VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
2539 (!FoundFlag && !InactiveFoundFlag))
2542 TrackLinkingRequiredFlag =
true;
2579 TrackLinkingRequiredFlag =
true;
2591 else if(FoundFlag || InactiveFoundFlag)
2610 bool BothPointFillets =
true;
2625 TrackLinkingRequiredFlag =
true;
2655 ShowMessage(
"Gaps must be set before track can be validated");
2665 throw Exception(
"Error, gaps unset when TryToConnectTrack called");
2676 if(!
LinkTrack(1, LocError, HLoc, VLoc,
false))
2693 ShowMessage(
"Error in RepositionAndMapTrack during TryToConnectTrack. Railway file is corrupt, further use may cause a system crash");
2700 if(!
LinkTrack(2, LocError, HLoc, VLoc,
true))
2724 std::pair<AnsiString, char>TempMapPair;
2732 TempMapPair.second =
'x';
2742 AnsiString Name =
"";
2743 typedef std::list<AnsiString> TNoPlatsList;
2744 TNoPlatsList::iterator NPLIt;
2745 TNoPlatsList NoPlatsList;
2746 typedef std::list<AnsiString> TLocNameList;
2747 TLocNameList LocNameList;
2752 LocNameList.push_back(LNMMIt->first);
2755 LocNameList.unique();
2756 for(TLocNameList::iterator LNLIt = LocNameList.begin(); LNLIt != LocNameList.end(); LNLIt++)
2760 if(MMRange.first == MMRange.second)
2766 if((LNMMIt->second) < 0)
2780 TempIt = MMRange.second;
2781 if(LNMMIt == --TempIt)
2783 NoPlatsList.push_back(Name);
2787 if(!NoPlatsList.empty())
2789 AnsiString NoPlatsAnsiList =
"";
2790 for(NPLIt = NoPlatsList.begin(); NPLIt != NoPlatsList.end(); NPLIt++)
2792 NoPlatsAnsiList += *NPLIt +
'\n';
2796 if(NoPlatsList.size() > 1)
2798 ShowMessage(
"Please note: the following locations have no platforms, trains won't be able to stop or pass there:-\n\n" + NoPlatsAnsiList +
"\nThis message will not be shown again.");
2802 ShowMessage(
"Please note: the following location has no platforms, trains won't be able to stop or pass there:-\n\n" + NoPlatsAnsiList +
"\nThis message will not be shown again.");
2817 int NewHLoc, NewVLoc;
2818 bool ConnectionFoundFlag, LinkFoundFlag;
2820 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2822 for(
unsigned int y = 0; y < 4; y++)
2840 ConnectionFoundFlag =
false;
2841 for(
unsigned int z = 0; z <
TrackVector.size(); z++)
2847 ConnectionFoundFlag =
true;
2849 LinkFoundFlag =
false;
2850 for(
unsigned int a = 0; a < 4; a++)
2854 LinkFoundFlag =
true;
2870 if(!ConnectionFoundFlag)
2945 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2962 bool UnsetGaps =
false;
2969 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2973 for(
unsigned int y = 0; y < 4; y++)
2985 for(
unsigned int y = 0; y < 4; y++)
2995 for(
unsigned int y = 1; y < 4; y++)
3004 for(
unsigned int y = 0; y < 4; y++)
3017 for(
unsigned int y = 0; y < 4; y++)
3045 int NumberOfActiveElements = 0;
3047 GraphicsFollow =
false;
3051 if(MarkerString[MarkerString.Length()] ==
'1')
3053 GraphicsFollow =
true;
3055 for(
int x = 0; x < NumberOfActiveElements; x++)
3061 TrackElement.
HLoc = TempInt;
3063 TrackElement.
VLoc = TempInt;
3069 TrackElement.
Conn[0] = TempInt;
3093 if((TempInt != -1) && (TempInt < 10))
3103 if((TempInt != -1) && (TempInt < 10))
3120 if(Marker[1] ==
'3')
3124 else if(Marker[1] ==
'2')
3128 else if(Marker[1] ==
'G')
3142 int NumberOfInactiveElements = 0;
3146 for(
int x = 0; x < NumberOfInactiveElements; x++)
3152 TrackElement.
HLoc = TempInt;
3154 TrackElement.
VLoc = TempInt;
3160 bool LocError =
false;
3189 for(
int x = 0; x < NumberOfGraphics; x++)
3200 bool FileError =
false;
3202 for(
int x = 0; x < NumberOfGraphics; x++)
3215 UGME.second =
new TPicture;
3216 UGME.second->LoadFromFile(
UGME.first);
3219 throw Exception(
"Map Insertion Error 2 - UserGraphicMap insertion failure for " + UGI.
FileName);
3226 catch(
const EInvalidGraphic &e)
3235 delete UGMIt->second;
3240 catch(
const Exception &e)
3249 delete UGMIt->second;
3257 bool FoundInMap =
false;
3276 UGME.second =
new TPicture;
3277 UGME.second->LoadFromFile(
UGME.first);
3280 throw Exception(
"Map Insertion Error 3 - UserGraphicMap insertion failure for " + UGI.
FileName);
3287 catch(
const EInvalidGraphic &e)
3296 delete UGMIt->second;
3301 catch(
const Exception &e)
3310 delete UGMIt->second;
3335 VecFile <<
"**Active elements**1" <<
'\0' <<
'\n';
3339 VecFile <<
"**Active elements**" <<
'\0' <<
'\n';
3341 for(
unsigned int x = 0; x < (
TrackVector.size()); x++)
3344 VecFile << x <<
'\n';
3345 VecFile << TrackElement.
SpeedTag <<
'\n';
3346 VecFile << TrackElement.
HLoc <<
'\n';
3347 VecFile << TrackElement.
VLoc <<
'\n';
3351 VecFile << TrackElement.
Conn[0] <<
'\n';
3355 VecFile << TrackElement.
Attribute <<
'\n';
3361 VecFile << int(1) <<
'\n';
3365 VecFile << int(0) <<
'\n';
3368 VecFile << TrackElement.
Length01 <<
'\n';
3369 VecFile << TrackElement.
Length23 <<
'\n';
3372 VecFile << TrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
3379 VecFile <<
"3*****" <<
'\0' <<
'\n';
3383 VecFile <<
"2*****" <<
'\0' <<
'\n';
3387 VecFile <<
"G*****" <<
'\0' <<
'\n';
3391 VecFile <<
"4*****" <<
'\0' <<
'\n';
3396 VecFile <<
"******" <<
'\0' <<
'\n';
3401 VecFile <<
"**Inactive elements**" <<
'\0' <<
'\n';
3405 VecFile << x <<
'\n';
3406 VecFile << InactiveTrackElement.
SpeedTag <<
'\n';
3407 VecFile << InactiveTrackElement.
HLoc <<
'\n';
3408 VecFile << InactiveTrackElement.
VLoc <<
'\n';
3409 VecFile << InactiveTrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
3410 VecFile <<
"******" <<
'\0' <<
'\n';
3425 GraphicsFollow =
false;
3427 if((NumberOfActiveElements < 0) || (NumberOfActiveElements > 1000000))
3433 AnsiString MarkerString;
3440 if(MarkerString[MarkerString.Length()] ==
'1')
3442 GraphicsFollow =
true;
3444 for(
int x = 0; x < NumberOfActiveElements; x++)
3452 int SpeedTag = TempInt;
3459 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3465 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3470 if((SpeedTag > 87) && (SpeedTag < 96))
3473 if((TempInt < -1) || (TempInt > 3))
3479 if((TempInt < -1) || (TempInt > 999999))
3485 if(((SpeedTag >= 7) && (SpeedTag <= 14)) || ((SpeedTag >= 28) && (SpeedTag <= 43)) || ((SpeedTag >= 132) && (SpeedTag <= 139)) ||
3486 ((SpeedTag >= 68) && (SpeedTag <= 75)))
3489 if((TempInt < -1) || (TempInt > 5))
3495 if((SpeedTag >= 68) && (SpeedTag <= 75))
3498 if((TempInt != 0) && (TempInt != 1))
3505 if((TempInt < -1) || (TempInt > 999999))
3511 if((TempInt < -1) || (TempInt > 999999))
3517 if((TempInt < -1) || (TempInt > 999999))
3523 if((TempInt < -1) || (TempInt > 999999))
3544 int NumberOfInactiveElements = 0;
3547 if(NumberOfInactiveElements < 0)
3557 for(
int x = 0; x < NumberOfInactiveElements; x++)
3571 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3577 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3604 if((NumberOfGraphics < 0) || (NumberOfGraphics > 100000))
3610 AnsiString FileName =
"", TempStr =
"";
3612 for(
int x = 0; x < NumberOfGraphics; x++)
3614 TPicture *TempPicture =
new TPicture;
3623 TempPicture->LoadFromFile(GraphicsPath +
"\\" + FileName);
3636 catch(
const EInvalidGraphic &e)
3641 for(
int y = x + 1; y < NumberOfGraphics; y++)
3647 ShowMessage(FileName +
3648 " has an incorrect file format, user graphics can't be loaded. Ensure that all user graphic files are valid with extension .bmp, .gif, .jpg, or .png");
3653 catch(
const Exception &e)
3658 for(
int y = x + 1; y < NumberOfGraphics; y++)
3664 ShowMessage(
"Unable to load user graphic files, ensure that " + FileName +
3665 " exists in the 'Graphics' folder and that it is has extension .bmp, .gif, .jpg, or .png.");
3683 for(
int x = 0; x < VecSize; x++)
3706 for(
int x = 0; x < VecSize; x++)
3728 for(
int x = 0; x < VecSize; x++)
3782 for(
int x = 0; x < VecSize; x++)
3840 PlotPoints(5, Next, Disp, BothPointFilletsAndBasicLCs);
3862 if(BothPointFilletsAndBasicLCs)
3937 Bitmap->Canvas->CopyMode = cmSrcCopy;
3939 Graphics::TBitmap *GraphicOutput;
4114 for(
int x = 0; x < 40; x++)
4143 Graphics::TBitmap *GraphicPtr;
4158 Graphics::TBitmap* SignalPlatformGraphic;
4191 if(OldTransparentColour !=
clB5G5R5)
4214 Bitmap->Canvas->CopyMode = cmSrcCopy;
4242 Bitmap->Canvas->CopyMode = cmSrcCopy;
4244 Graphics::TBitmap *GraphicOutput;
4254 if(BaseElement == 1)
4350 for(
int x = 0; x < 40; x++)
4379 Graphics::TBitmap *GraphicPtr;
4394 Graphics::TBitmap* SignalPlatformGraphic;
4457 for(
int x = 0; x < 40; x++)
4465 Graphics::TBitmap* SignalPlatformGraphic;
4506 if(OldTransparentColour !=
clB5G5R5)
4520 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4592 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4606 ShowMessage(
"Error - gap connected to a non-gap. Railway file is corrupt, further use may cause a system crash");
4632 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4657 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4687 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4721 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4758 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4775 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4796 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4828 for(TrackMapPtr =
TrackMap.begin(); TrackMapPtr !=
TrackMap.end(); TrackMapPtr++)
4835 throw Exception(
"Error - Map & Vector different sizes");
4837 unsigned int NonZeroCount = 0;
4839 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4848 throw Exception(
"Error - NewVector & NonZero TrackVector different sizes");
4854 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4858 TrackMapEntry.first = TrackMapKeyPair;
4859 TrackMapEntry.second = x;
4860 if(!(
TrackMap.insert(TrackMapEntry).second))
4862 throw Exception(
"Error - map insertion failure, TrackVector in error");
4866 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4868 for(
unsigned int y = 0; y < 4; y++)
4893 THVPair GapMapKeyPair, GapMapValuePair;
4896 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4902 GapMapEntry.first = GapMapKeyPair;
4905 throw Exception(
"Error - Gap connection == -1 Can't build GapMap");
4909 GapMapEntry.second = GapMapValuePair;
4912 GapMap.insert(GapMapEntry);
4927 bool TrackElementPositionsOK =
true;
4929 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4941 "Footbridge or underpass connection error. Each end must connect to a platform, concourse "
4942 "or other footbridge or underpass, and they can't connect to each other (i.e. a footbridge "
4943 "can't connect to an underpass or vice versa)");
4951 for(
unsigned int y = 0; y < 4; y++)
4969 bool ConnectionFoundFlag;
4973 ShowMessage(
"Can't have a track element adjacent to a continuation exit");
4979 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
4988 if(ConnectionFoundFlag)
4993 bool ExitSignal =
false;
5004 ShowMessage(
"Can't have an exit signal next to a level crossing - it can cause the train to foul the crossing in some circumstances");
5006 TrackElementPositionsOK =
false;
5011 ShowMessage(
"Can't have points, crossover or signal next to buffers - need room for a train without fouling");
5013 TrackElementPositionsOK =
false;
5018 ShowMessage(
"Can't have points, crossover, bridge or signal next to a continuation - it can cause route setting problems");
5022 TrackElementPositionsOK =
false;
5027 ShowMessage(
"Can't have two same-direction signals adjacent to each other as there is no room for a train between them");
5030 TrackElementPositionsOK =
false;
5042 ShowMessage(
"Bridge next to a signal - routes can't be truncated to this or other such signals.\n\nThis restriction can be removed or reinstated by pressing\nCTRL ALT 5. When removed this message will not be shown again.");
5045 TrackElementPositionsOK =
false;
5050 ShowMessage(
"Can't have two level crossings adjacent to each other on the same track");
5051 TrackElementPositionsOK =
false;
5054 if(!TrackElementPositionsOK)
5061 throw Exception(
"Error in track element positions in FinalCall");
5074 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5080 for(
unsigned int y = 0; y < 4; y++)
5102 bool ConnectionFoundFlag;
5103 bool LinkMatchFound =
false;
5106 if(ConnectionFoundFlag)
5108 for(
unsigned int a = 0; a < 4; a++)
5114 LinkMatchFound =
true;
5125 throw Exception(
"Error in final track linkage - - no matching link found");
5138 throw Exception(
"Error in final track linkage - connection not found");
5154 bool ConnErrorFlag =
false;
5156 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5160 ConnErrorFlag =
true;
5164 ConnErrorFlag =
true;
5168 ConnErrorFlag =
true;
5172 ConnErrorFlag =
true;
5181 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
5190 throw Exception(
"ConnError in LinkTrack - Final");
5194 throw Exception(
"ConnError in LinkTrack - Precheck");
5197 bool CLkErrorFlag =
false;
5199 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5203 CLkErrorFlag =
true;
5207 CLkErrorFlag =
true;
5211 CLkErrorFlag =
true;
5215 CLkErrorFlag =
true;
5223 throw Exception(
"CLkError in LinkTrack - Final");
5227 throw Exception(
"CLkError in LinkTrack - Precheck");
5232 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5262 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5278 for(
unsigned int y = 0; y < 4; y++)
5297 bool ConnectionFoundFlag;
5303 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
5312 if(ConnectionFoundFlag)
5315 bool LinkFoundFlag =
false;
5372 for(
unsigned int a = 0; a < 4; a++)
5381 LinkFoundFlag =
true;
5389 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - invalid link");
5399 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - connection not found");
5413 bool ConnErrorFlag =
false;
5415 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5419 ConnErrorFlag =
true;
5423 ConnErrorFlag =
true;
5427 ConnErrorFlag =
true;
5431 ConnErrorFlag =
true;
5440 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
5449 throw Exception(
"ConnError in LinkTrack - Final");
5453 throw Exception(
"ConnError in LinkTrack - Precheck");
5456 bool CLkErrorFlag =
false;
5458 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5462 CLkErrorFlag =
true;
5466 CLkErrorFlag =
true;
5470 CLkErrorFlag =
true;
5474 CLkErrorFlag =
true;
5482 throw Exception(
"CLkError in LinkTrack - Final");
5486 throw Exception(
"CLkError in LinkTrack - Precheck");
5490 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5519 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5535 for(
unsigned int y = 0; y < 4; y++)
5554 bool ConnectionFoundFlag =
false;
5556 if(ConnectionFoundFlag)
5560 bool LinkFoundFlag =
false;
5580 for(
unsigned int a = 0; a < 4; a++)
5589 LinkFoundFlag =
true;
5609 bool ConnErrorFlag =
false;
5611 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5615 ConnErrorFlag =
true;
5619 ConnErrorFlag =
true;
5623 ConnErrorFlag =
true;
5627 ConnErrorFlag =
true;
5635 bool CLkErrorFlag =
false;
5637 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5641 CLkErrorFlag =
true;
5645 CLkErrorFlag =
true;
5649 CLkErrorFlag =
true;
5653 CLkErrorFlag =
true;
5671 int Position1, Position2;
5677 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
5679 int HLoc1 = GapMapPtr->first.first;
5680 int VLoc1 = GapMapPtr->first.second;
5681 int HLoc2 = GapMapPtr->second.first;
5682 int VLoc2 = GapMapPtr->second.second;
5685 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
5689 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
5693 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
5697 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
5715 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
5716 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
5726 bool FoundFlag =
false;
5738 InactiveTrackMapKeyPair.first = TrackElement.
HLoc;
5739 InactiveTrackMapKeyPair.second = TrackElement.
VLoc;
5740 InactiveTrackMapEntry.first = InactiveTrackMapKeyPair;
5769 bool FoundFlag =
false;
5782 TrackMapKeyPair.first = TrackElement.
HLoc;
5783 TrackMapKeyPair.second = TrackElement.
VLoc;
5784 TrackMapEntry.first = TrackMapKeyPair;
5789 LocationNameEntry.second = -(int)(
TrackVector.size());
5829 TrackMapKeyPair.first = HLoc;
5830 TrackMapKeyPair.second = VLoc;
5831 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5841 return(TrackMapPtr->second);
5854 TrackMapKeyPair.first = HLoc;
5855 TrackMapKeyPair.second = VLoc;
5856 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5859 AnsiString Message =
"Element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5860 throw Exception(Message);
5878 MapKeyPair.first = HLoc;
5879 MapKeyPair.second = VLoc;
5880 MapPtr = Map.find(MapKeyPair);
5881 if(MapPtr == Map.end())
5883 AnsiString Message =
"Element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc) +
" in GetTrackElementFromAnyTrackMap";
5884 throw Exception(Message);
5889 return(Vector.at(MapPtr->second));
5899 THVPair InactiveTrackMapKeyPair;
5902 InactiveTrackMapKeyPair.first = HLoc;
5903 InactiveTrackMapKeyPair.second = VLoc;
5907 AnsiString Message =
"Inactive element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5908 throw Exception(Message);
5922 bool Present =
true;
5926 TrackMapKeyPair.first = HLoc;
5927 TrackMapKeyPair.second = VLoc;
5928 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5943 bool Present =
true;
5944 THVPair InactiveTrackMapKeyPair;
5947 InactiveTrackMapKeyPair.first = HLoc;
5948 InactiveTrackMapKeyPair.second = VLoc;
5966 THVPair InactiveTrackMapKeyPair;
5971 InactiveTrackMapKeyPair.first = HLoc;
5972 InactiveTrackMapKeyPair.second = VLoc;
5981 if(InactiveTrackRange.first == InactiveTrackRange.second)
5990 RetPair.first = InactiveTrackRange.first->second;
5991 RetPair.second = (--InactiveTrackRange.second)->second;
6004 AnsiString(DivergingPosition));
6015 if(((SpeedTag1 == 7) && (SpeedTag2 == 10)) ||
6016 ((SpeedTag1 == 10) && (SpeedTag2 == 7)) || ((SpeedTag1 == 8) && (SpeedTag2 == 9)) || ((SpeedTag1 == 9) && (SpeedTag2 == 8)) ||
6017 ((SpeedTag1 == 11) && (SpeedTag2 == 14)) ||
6018 ((SpeedTag1 == 14) && (SpeedTag2 == 11)) || ((SpeedTag1 == 12) && (SpeedTag2 == 13)) || ((SpeedTag1 == 13) && (SpeedTag2 == 12)) ||
6019 ((SpeedTag1 == 28) && (SpeedTag2 == 31)) ||
6020 ((SpeedTag1 == 31) && (SpeedTag2 == 28)) || ((SpeedTag1 == 29) && (SpeedTag2 == 30)) || ((SpeedTag1 == 30) && (SpeedTag2 == 29)) ||
6021 ((SpeedTag1 == 32) && (SpeedTag2 == 35)) ||
6022 ((SpeedTag1 == 35) && (SpeedTag2 == 32)) || ((SpeedTag1 == 33) && (SpeedTag2 == 34)) || ((SpeedTag1 == 34) && (SpeedTag2 == 33)) ||
6023 ((SpeedTag1 == 36) && (SpeedTag2 == 39)) ||
6024 ((SpeedTag1 == 39) && (SpeedTag2 == 36)) || ((SpeedTag1 == 37) && (SpeedTag2 == 38)) || ((SpeedTag1 == 38) && (SpeedTag2 == 37)) ||
6025 ((SpeedTag1 == 40) && (SpeedTag2 == 43)) ||
6026 ((SpeedTag1 == 43) && (SpeedTag2 == 40)) || ((SpeedTag1 == 41) && (SpeedTag2 == 42)) || ((SpeedTag1 == 42) && (SpeedTag2 == 41)))
6060 throw Exception(
"Error, Wrong track type in PlotGap");
6062 if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] > -1))
6066 else if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] == -1))
6070 if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] > -1))
6074 else if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] == -1))
6078 if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] > -1))
6082 else if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] == -1))
6086 if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] > -1))
6090 else if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] == -1))
6094 if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] > -1))
6098 else if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] == -1))
6102 if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] > -1))
6106 else if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] == -1))
6110 if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] > -1))
6114 else if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] == -1))
6118 if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] > -1))
6122 else if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] == -1))
6138 PosPair.first = TrackElement.
HLoc;
6139 PosPair.second = TrackElement.
VLoc;
6143 Disp->
PlotOutput(283, TrackElement.
HLoc * 16, TrackElement.
VLoc * 16, MOMIt->second);
6156 throw Exception(
"Error, Wrong track type in PlotPoints");
6160 bool FoundFlag =
false;
6162 if(IMPair.first > 0)
6178 else if(TrackElement.
SpeedTag < 132)
6189 else if(!TrackElement.
Failed)
6196 else if(TrackElement.
SpeedTag < 132)
6214 else if(TrackElement.
SpeedTag < 132)
6228 bool BlueLoc =
false;
6237 if(FoundFlag && !BlueLoc)
6252 bool FoundFlag =
false;
6255 throw Exception(
"Error, Wrong track type in PlotSignal");
6259 for(
int x = 0; x < 40; x++)
6275 if(IMPair.first > 0)
6342 for(
int x = 0; x < 40; x++)
6349 Graphics::TBitmap* SignalPlatformGraphic;
6351 if(IMPair.first > 0)
6373 for(
int x = 0; x < 8; x++)
6380 if(IMPair.first > 0)
6397 for(
int x = 0; x < 8; x++)
6404 if(IMPair.first > 0)
6497 while(
IsLCAtHV(0, HLoc, (VLoc + UpStep)))
6505 while(
IsLCAtHV(1, HLoc, (VLoc + DownStep)))
6513 while(
IsLCAtHV(2, (HLoc + LeftStep), VLoc))
6521 while(
IsLCAtHV(3, (HLoc + RightStep), VLoc))
6537 while(
IsLCAtHV(51, HLoc, (VLoc + UpStep)))
6545 while(
IsLCAtHV(52, HLoc, (VLoc + DownStep)))
6553 while(
IsLCAtHV(53, (HLoc + LeftStep), VLoc))
6561 while(
IsLCAtHV(54, (HLoc + RightStep), VLoc))
6594 while(
IsLCAtHV(55, HLoc, (VLoc + UpStep)))
6606 while(
IsLCAtHV(56, HLoc, (VLoc + DownStep)))
6618 while(
IsLCAtHV(57, (HLoc + LeftStep), VLoc))
6630 while(
IsLCAtHV(58, (HLoc + RightStep), VLoc))
6672 throw Exception(
"Error, Wrong track type in PlotAndLowerLevelCrossingBarriers");
6674 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6676 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndLowerLevelCrossingBarriers");
6679 if(BaseElementSpeedTag == 1)
6683 while(
IsLCAtHV(5, HLoc, (VLoc + UpStep)))
6690 while(
IsLCAtHV(6, HLoc, (VLoc + DownStep)))
6698 Graphics::TBitmap *RouteGraphic;
6700 if(TypeOfRoute == 1)
6704 else if(TypeOfRoute == 0)
6710 RouteGraphic = BaseGraphic;
6717 if(UpStep == DownStep)
6720 Disp->
PlotOutput(133, HLoc * 16, VLoc * 16, RouteGraphic);
6730 else if((DownStep - UpStep) == 1)
6735 Disp->
PlotOutput(136, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
6745 Disp->
PlotOutput(139, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6758 Disp->
PlotOutput(196, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6768 Disp->
PlotOutput(199, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
6784 Disp->
PlotOutput(142, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
6794 Disp->
PlotOutput(145, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6804 else if(DownStep == 0)
6807 Disp->
PlotOutput(202, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6817 Disp->
PlotOutput(205, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
6830 Disp->
PlotOutput(208, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6840 Disp->
PlotOutput(211, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6850 for(
int x = (UpStep + 1); x < DownStep; x++)
6855 Disp->
PlotOutput(148, HLoc * 16, (VLoc + x) * 16, RouteGraphic);
6859 Disp->
PlotOutput(213, HLoc * 16, (VLoc + x) * 16, BaseGraphic);
6880 while(
IsLCAtHV(7, (HLoc + LStep), VLoc))
6887 while(
IsLCAtHV(8, (HLoc + RStep), VLoc))
6893 Graphics::TBitmap *RouteGraphic;
6895 if(TypeOfRoute == 1)
6899 else if(TypeOfRoute == 0)
6905 RouteGraphic = BaseGraphic;
6914 Disp->
PlotOutput(151, HLoc * 16, VLoc * 16, RouteGraphic);
6924 else if((RStep - LStep) == 1)
6929 Disp->
PlotOutput(154, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6939 Disp->
PlotOutput(157, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6952 Disp->
PlotOutput(215, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6962 Disp->
PlotOutput(218, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
6978 Disp->
PlotOutput(160, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6988 Disp->
PlotOutput(163, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
7001 Disp->
PlotOutput(221, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
7011 Disp->
PlotOutput(224, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
7024 Disp->
PlotOutput(227, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
7034 Disp->
PlotOutput(230, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
7044 for(
int x = (LStep + 1); x < RStep; x++)
7049 Disp->
PlotOutput(166, (HLoc + x) * 16, VLoc * 16, RouteGraphic);
7053 Disp->
PlotOutput(232, (HLoc + x) * 16, VLoc * 16, BaseGraphic);
7077 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7080 throw Exception(
"Error, Wrong track type in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
7082 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
7084 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
7087 if(BaseElementSpeedTag == 1)
7091 while(
IsLCAtHV(30, HLoc, (VLoc + UpStep)))
7098 while(
IsLCAtHV(31, HLoc, (VLoc + DownStep)))
7104 if(UpStep == DownStep)
7115 else if((DownStep - UpStep) == 1)
7134 for(
int x = (UpStep + 1); x < DownStep; x++)
7143 for(
int x = (UpStep + 1); x < DownStep; x++)
7150 for(
int x = UpStep; x <= DownStep; x++)
7163 while(
IsLCAtHV(32, (HLoc + LStep), VLoc))
7170 while(
IsLCAtHV(33, (HLoc + RStep), VLoc))
7187 else if((RStep - LStep) == 1)
7206 for(
int x = (LStep + 1); x < RStep; x++)
7215 for(
int x = (LStep + 1); x < RStep; x++)
7222 for(
int x = LStep; x <= RStep; x++)
7241 throw Exception(
"Error, Wrong track type in PlotAndRaiseLevelCrossingBarriers");
7243 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
7245 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndRaiseLevelCrossingBarriers");
7248 if(BaseElementSpeedTag == 1)
7252 while(
IsLCAtHV(10, HLoc, (VLoc + UpStep)))
7259 while(
IsLCAtHV(11, HLoc, (VLoc + DownStep)))
7265 for(
int x = UpStep; x < (DownStep + 1); x++)
7280 while(
IsLCAtHV(12, (HLoc + LStep), VLoc))
7287 while(
IsLCAtHV(13, (HLoc + RStep), VLoc))
7293 for(
int x = LStep; x < (RStep + 1); x++)
7312 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7315 throw Exception(
"Error, Wrong track type in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
7317 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
7319 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
7324 if(BaseElementSpeedTag == 1)
7328 while(
IsLCAtHV(35, HLoc, (VLoc + UpStep)))
7335 while(
IsLCAtHV(36, HLoc, (VLoc + DownStep)))
7341 for(
int x = UpStep; x <= DownStep; x++)
7355 while(
IsLCAtHV(37, (HLoc + LStep), VLoc))
7362 while(
IsLCAtHV(38, (HLoc + RStep), VLoc))
7368 for(
int x = LStep; x <= RStep; x++)
7384 Graphics::TBitmap *RouteGraphic;
7387 if(BaseElementSpeedTag == 1)
7389 if(TypeOfRoute == 1)
7393 else if(TypeOfRoute == 0)
7399 RouteGraphic = BaseGraphic;
7403 RouteGraphic = BaseGraphic;
7409 if(TypeOfRoute == 1)
7413 else if(TypeOfRoute == 0)
7419 RouteGraphic = BaseGraphic;
7423 RouteGraphic = BaseGraphic;
7428 while(
IsLCAtHV(14, HLoc, (VLoc + UpStep)))
7433 Disp->
PlotOutput(175, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
7437 Disp->
PlotOutput(234, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
7444 while(
IsLCAtHV(15, HLoc, (VLoc + DownStep)))
7447 Disp->
PlotOutput(177, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
7452 while(
IsLCAtHV(16, (HLoc + LeftStep), VLoc))
7457 Disp->
PlotOutput(235, (HLoc + LeftStep) * 16, VLoc * 16, RouteGraphic);
7461 Disp->
PlotOutput(236, (HLoc + LeftStep) * 16, VLoc * 16, BaseGraphic);
7468 while(
IsLCAtHV(17, (HLoc + RightStep), VLoc))
7471 Disp->
PlotOutput(238, (HLoc + RightStep) * 16, VLoc * 16, BaseGraphic);
7596 throw Exception(
"Element not found in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
7600 throw Exception(
"Element not a level crossing in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
7631 "," + AnsiString(VLoc));
7635 int DummyRouteNumber;
7637 TrainPresent =
false;
7641 while(
IsLCAtHV(25, HLoc, (VLoc + UpStep)))
7643 TrackMapKeyPair.first = HLoc;
7644 TrackMapKeyPair.second = VLoc + UpStep;
7645 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7654 TrainPresent =
true;
7668 while(
IsLCAtHV(26, HLoc, (VLoc + DownStep)))
7670 TrackMapKeyPair.first = HLoc;
7671 TrackMapKeyPair.second = VLoc + DownStep;
7672 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7681 TrainPresent =
true;
7695 while(
IsLCAtHV(27, (HLoc + LeftStep), VLoc))
7697 TrackMapKeyPair.first = HLoc + LeftStep;
7698 TrackMapKeyPair.second = VLoc;
7699 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7708 TrainPresent =
true;
7722 while(
IsLCAtHV(28, (HLoc + RightStep), VLoc))
7724 TrackMapKeyPair.first = HLoc + RightStep;
7725 TrackMapKeyPair.second = VLoc;
7726 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7735 TrainPresent =
true;
7755 for(
unsigned int x = 0; x < SearchVector.size(); x++)
7772 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7775 throw Exception(
"PlotSmallFlashingLinkedLevelCrossings");
7781 while(
IsLCAtHV(61, HLoc, (VLoc + UpStep)))
7788 while(
IsLCAtHV(62, HLoc, (VLoc + DownStep)))
7794 for(
int x = UpStep; x <= DownStep; x++)
7801 while(
IsLCAtHV(63, (HLoc + LStep), VLoc))
7808 while(
IsLCAtHV(64, (HLoc + RStep), VLoc))
7814 for(
int x = LStep; x <= RStep; x++)
7830 throw Exception(
"Error, Wrong track type in GetFilletGraphic");
7837 else if(TrackElement.
SpeedTag < 132)
7855 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
7872 AnsiString(ScreenPosV));
7887 AnsiString(ScreenPosV));
7898 AnsiString(VPosTrue));
7912 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
7924 throw Exception(
"CheckMapAndTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
7925 " in TrackMap, Caller=" + (AnsiString)Caller);
7927 if(MapVecPos != (
int)a)
7929 throw Exception(
"CheckMapAndTrack Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
7930 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)MapVecPos +
" TrackVectorPos value=" + (AnsiString)a +
" Caller=" +
7931 (AnsiString)Caller);
7937 throw Exception(
"CheckMapAndTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
7938 " Caller=" + (AnsiString)Caller);
7958 throw Exception(
"CheckMapAndInactiveTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
7959 " in InactiveMap, Caller=" + (AnsiString)Caller);
7961 if((InactivePair.first != a) && (InactivePair.second != a))
7963 throw Exception(
"CheckMapAndInactiveTrack Error - InactiveMapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
7964 (AnsiString)CheckElement.
VLoc +
" Inactive Map values=" + (AnsiString)InactivePair.first +
" and " + (AnsiString)InactivePair.second +
7965 " InactiveTrackVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
7970 throw Exception(
"CheckMapAndInactiveTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
7971 " Caller=" + (AnsiString)Caller);
7981 int Position1, Position2;
7987 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
7989 int HLoc1 = GapMapPtr->first.first;
7990 int VLoc1 = GapMapPtr->first.second;
7991 int HLoc2 = GapMapPtr->second.first;
7992 int VLoc2 = GapMapPtr->second.second;
7995 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
7999 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
8003 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
8007 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
8011 unsigned int GapCount = 0;
8013 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
8021 if((
GapMap.size() * 2) != GapCount)
8023 throw Exception(
"GapMap Error - Map Size * 2 =" + (AnsiString)(
GapMap.size() * 2) +
" GapCount=" + (AnsiString)GapCount +
" Caller=" +
8024 (AnsiString)Caller);
8034 if((TrackElement.
HLoc == -2000000000) || (TrackElement.
VLoc == -2000000000))
8038 throw Exception(
"Error - TrackFinished with erase element still present");
8043 AnsiString IDString;
8045 if(TrackElement.
HLoc < 0)
8047 IDString =
"N" + AnsiString(abs(TrackElement.
HLoc)) +
"-";
8051 IDString = AnsiString(TrackElement.
HLoc) +
"-";
8053 if(TrackElement.
VLoc < 0)
8055 IDString +=
"N" + AnsiString(abs(TrackElement.
VLoc));
8059 IDString += AnsiString(TrackElement.
VLoc);
8074 for(
int x = 1; x < String.Length() + 1; x++)
8076 if(String.IsDelimiter(
"-", x))
8081 if(x == String.Length())
8085 ShowMessage(
"Error in track element identifier: <" + String +
"> - no delimiter");
8095 ShowMessage(
"Error in track element identifier: <" + String +
"> - No Horizontal value");
8100 if(DelimPos == String.Length())
8104 ShowMessage(
"Error in track element identifier <" + String +
"> - No Vertical value");
8109 if((String[String.Length()] <
'0') || (String[String.Length()] >
'9'))
8113 ShowMessage(
"Error in track element identifier <" + String +
"> - Last value is not a number");
8120 if(String.SubString(1, 1) !=
"N")
8122 for(
int x = 1; x < DelimPos; x++)
8124 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8128 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
8135 if(String.SubString(1, 1) ==
"N")
8137 for(
int x = 2; x < DelimPos; x++)
8139 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8143 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
8150 if(String.SubString(1, 1) ==
"N")
8152 HLoc = -(String.SubString(2, DelimPos - 2).ToInt());
8156 HLoc = String.SubString(1, DelimPos - 1).ToInt();
8158 if(String.SubString(DelimPos + 1, 1) !=
"N")
8160 for(
int x = DelimPos + 1; x < String.Length() + 1; x++)
8162 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8166 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
8173 if(String.SubString(DelimPos + 1, 1) ==
"N")
8175 for(
int x = DelimPos + 2; x < String.Length() + 1; x++)
8177 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8181 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
8188 if(String.SubString(DelimPos + 1, 1) ==
"N")
8190 VLoc = -(String.SubString(DelimPos + 2, String.Length() - DelimPos - 1).ToInt());
8194 VLoc = String.SubString(DelimPos + 1, String.Length() - DelimPos).ToInt();
8199 TrackMapPtr =
TrackMap.find(HVPair);
8204 ShowMessage(
"No track element corresponding to track element identifier: <" + String +
">");
8210 return(TrackMapPtr->second);
8212 catch(
const Exception &e)
8215 ShowMessage(
"Syntax error in track element identifier: <" + String +
">");
8229 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
8230 int HLoc = TrackElement.
HLoc;
8231 int VLoc = TrackElement.
VLoc;
8334 AnsiString(SpeedTag));
8345 if(HVRange.first == HVRange.second)
8352 HVIt1 = HVRange.first;
8357 if(--HVRange.second != HVRange.first)
8359 HVIt2 = HVRange.second;
8363 HVIt2->second).
SpeedTag == SpeedTag)))
8383 AnsiString(SpeedTag));
8449 AnsiString TestString1, TestString2;
8454 throw Exception(
"LNPendingList size not 1 on entry");
8456 int CurrentElementNumber;
8457 bool FoundFlag =
false, ErasedFlag =
false;
8463 int H = CurrentElement->HLoc;
8464 int V = CurrentElement->VLoc;
8465 int Tag = CurrentElement->SpeedTag;
8471 for(
int x = 0; x < 25; x++)
8481 for(
int x = 0; x < 25; x++)
8491 for(
int x = 0; x < 25; x++)
8501 for(
int x = 0; x < 25; x++)
8511 for(
int x = 0; x < 28; x++)
8521 for(
int x = 0; x < 8; x++)
8531 for(
int x = 0; x < 8; x++)
8541 for(
int x = 0; x < 4; x++)
8557 bool FoundFlag2 =
false;
8575 for(
int x = 0; x < 8; x++)
8585 for(
int x = 0; x < 8; x++)
8598 if(CurrentElementNumber > -1)
8603 if((ExistingName !=
"") && (ExistingName != LocationName))
8619 AddName(1, CurrentElement, LocationName);
8623 LNDone2MultiMapEntry.first = HVPair;
8635 if(SNRange.first != SNRange.second)
8639 for(SNIterator = SNRange.second; SNIterator != SNRange.first; SNIterator--)
8646 TVIt->LocationName =
"";
8647 TVIt->ActiveTrackElementName =
"";
8681 std::pair<AnsiString, char>TempMapPair;
8689 TempMapPair.second =
'x';
8707 AnsiString(SpeedTag));
8717 if((SpeedTag == 129) || (SpeedTag == 130) || (SpeedTag == 145) || (SpeedTag == 146))
8724 int MapPos = -1 - Position;
8728 FoundElement = MapPos;
8744 FoundElement = IMPair.first;
8753 FoundElement = IMPair.second;
8774 AnsiString OldName = TrackElement->LocationName, ErrorString;
8776 TrackElement->LocationName = Name;
8777 int HLoc = TrackElement->HLoc;
8778 int VLoc = TrackElement->VLoc;
8792 if(ErrorString !=
"")
8794 throw Exception(ErrorString +
" in AddName for OldName == " + OldName);
8818 if(LNDone2MultiMapIterator->second == MapPos)
8845 if(*LNPendingListIterator == MapPos)
8918 if(NameBeingChecked !=
"")
8924 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
8932 NameBeingChecked = LNMMRg.second->first;
8934 if(NameBeingChecked !=
"")
8940 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
8961 if(LNMMIt->second < 0)
8971 HVPairsLinkedMap.insert(std::pair<THVPair, bool>(HVPair,
false));
8979 std::list<THVPair> HVLinkedList;
8982 HVPairsLinkedMap.begin()->second =
true;
8983 HVLinkedList.push_back(HVPairsLinkedMap.begin()->first);
8986 THVPair HVPairUnderExamination;
8987 THVPairsLinkedMap::iterator HVPLMIt;
8989 while(!HVLinkedList.empty())
8991 HVPairUnderExamination = HVLinkedList.front();
8992 HVLinkedList.pop_front();
8993 HVPairNew.first = HVPairUnderExamination.first;
8994 HVPairNew.second = HVPairUnderExamination.second - 1;
8995 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8996 if(HVPLMIt != HVPairsLinkedMap.end())
8998 if(!HVPLMIt->second)
9000 HVLinkedList.push_back(HVPLMIt->first);
9002 HVPLMIt->second =
true;
9004 HVPairNew.first = HVPairUnderExamination.first - 1;
9005 HVPairNew.second = HVPairUnderExamination.second;
9006 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
9007 if(HVPLMIt != HVPairsLinkedMap.end())
9009 if(!HVPLMIt->second)
9011 HVLinkedList.push_back(HVPLMIt->first);
9013 HVPLMIt->second =
true;
9015 HVPairNew.first = HVPairUnderExamination.first;
9016 HVPairNew.second = HVPairUnderExamination.second + 1;
9017 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
9018 if(HVPLMIt != HVPairsLinkedMap.end())
9020 if(!HVPLMIt->second)
9022 HVLinkedList.push_back(HVPLMIt->first);
9024 HVPLMIt->second =
true;
9026 HVPairNew.first = HVPairUnderExamination.first + 1;
9027 HVPairNew.second = HVPairUnderExamination.second;
9028 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
9029 if(HVPLMIt != HVPairsLinkedMap.end())
9031 if(!HVPLMIt->second)
9033 HVLinkedList.push_back(HVPLMIt->first);
9035 HVPLMIt->second =
true;
9040 for(THVPairsLinkedMap::iterator HVPLMIt = HVPairsLinkedMap.begin(); HVPLMIt != HVPairsLinkedMap.end(); HVPLMIt++)
9042 if(!HVPLMIt->second)
9061 if(LocationName ==
"")
9072 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9079 ActiveTrackElementNameMapEntry.second = 0;
9101 bool FoundFlag, ErasedFlag =
false;
9105 if(SNRange.first != SNRange.second)
9108 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9111 TVIt->LocationName =
"";
9112 TVIt->ActiveTrackElementName =
"";
9146 AnsiString(VLoc) +
"," + AnsiString(SpeedTag));
9148 AnsiString LocationName;
9157 if(LocationName !=
"")
9165 if(LocationName !=
"")
9179 if(LocationName !=
"")
9181 int ModifiedPosition = -1 - Position;
9190 for(
int x = 0; x < 25; x++)
9200 else if(SpeedTag == 77)
9202 for(
int x = 0; x < 25; x++)
9212 else if(SpeedTag == 78)
9214 for(
int x = 0; x < 25; x++)
9224 else if(SpeedTag == 79)
9226 for(
int x = 0; x < 25; x++)
9236 else if(SpeedTag == 96)
9238 for(
int x = 0; x < 28; x++)
9248 else if(SpeedTag == 129)
9250 for(
int x = 0; x < 8; x++)
9260 else if(SpeedTag == 130)
9262 for(
int x = 0; x < 8; x++)
9272 else if(SpeedTag == 145)
9274 for(
int x = 0; x < 8; x++)
9284 else if(SpeedTag == 146)
9286 for(
int x = 0; x < 8; x++)
9296 else if(SpeedTag == 131)
9298 for(
int x = 0; x < 4; x++)
9318 bool FoundFlag2 =
false;
9345 AnsiString(SpeedTag));
9357 if(TempElement->LocationName !=
"")
9359 LocationName = TempElement->LocationName;
9360 FoundElement = IMPair.first;
9368 if(TempElement->LocationName !=
"")
9370 LocationName = TempElement->LocationName;
9371 FoundElement = IMPair.second;
9383 if(TempElement->LocationName !=
"")
9385 LocationName = TempElement->LocationName;
9386 FoundElement = -1 - Position;
9402 unsigned int Count = 0;
9409 AnsiString SName, TName, ErrorString;
9411 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9417 throw Exception(
"Track element has FixedNamedLocationElement set but is not a footbridge/underpass in CheckLocationNameMultiMap, caller = " +
9418 AnsiString(Caller));
9431 (
"Inactive track element has FixedNamedLocationElement set but is not a platform, concourse or named location in CheckLocationNameMultiMap, caller = " +
9432 AnsiString(Caller));
9439 throw Exception(
"LocationNameMultiMap size = " + AnsiString(
LocationNameMultiMap.size()) +
" & Count = " + AnsiString(Count) +
9440 " in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9445 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9451 if(ErrorString !=
"")
9453 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for TrackVector check, caller = " + AnsiString(Caller));
9455 if(SNIt->second != -1 - (
int)x)
9457 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
9458 AnsiString(Caller));
9464 bool FoundFlag =
false;
9473 throw Exception(
"Track element with ActiveTrackElementName but no plat/named loc at H " + AnsiString(
TrackElementAt(1369, x).HLoc) +
" & V " +
9474 AnsiString(
TrackElementAt(1370, x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9478 throw Exception(
"Track element with ActiveTrackElementName " + TName +
" but plat/named loc at H " + AnsiString(
TrackElementAt(1371, x).HLoc) +
9479 " & V " + AnsiString(
TrackElementAt(1372, x).VLoc) +
" has different LocationName in CheckLocationNameMultiMap, caller = " +
9480 AnsiString(Caller));
9485 throw Exception(
"Track element with ActiveTrackElementName but no inactive element at H " + AnsiString(
TrackElementAt(1373, x).HLoc) +
" & V " +
9486 AnsiString(
TrackElementAt(1374, x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9496 if(ErrorString !=
"")
9498 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for InactiveTrackVector check, caller = " + AnsiString(Caller));
9500 if(SNIt->second != (
int)x)
9502 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
9503 AnsiString(Caller));
9513 AnsiString &ErrorString)
9521 AnsiString(TrackElement->HLoc) +
"," + AnsiString(TrackElement->VLoc) +
"," + AnsiString(TrackElement->SpeedTag));
9523 bool FoundFlag =
false;
9527 if(SNRange.first == SNRange.second)
9529 ErrorString =
"Error, Name " + LocationName +
" not found in map";
9531 return(SNRange.first);
9535 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9537 if(SNIterator->second < 0)
9539 int TVPos = -1 - SNIterator->second;
9541 if(TVIt == TrackElement)
9550 int ITVPos = SNIterator->second;
9552 if(ITVIt == TrackElement)
9563 ErrorString =
"Error, Name " + LocationName +
" found but not at required element";
9580 LocationNameEntry.first = NewName;
9581 LocationNameEntry.second = SNIterator->second;
9595 int TruePos = -1 - Position;
9599 throw Exception(
"Footbridge/underpass error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
9609 throw Exception(
"Inactive element error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
9632 InactiveTrack2MultiMapIterator++)
9634 if(InactiveTrack2MultiMapIterator->second > VecPos)
9636 InactiveTrack2MultiMapIterator->second--;
9644 LocationNameMultiMapIterator++)
9646 if(LocationNameMultiMapIterator->second < 0)
9650 if(LocationNameMultiMapIterator->second > (
int)VecPos)
9652 LocationNameMultiMapIterator->second--;
9674 for(TrackMapIterator =
TrackMap.begin(); TrackMapIterator !=
TrackMap.end(); TrackMapIterator++)
9676 if(TrackMapIterator->second > VecPos)
9678 TrackMapIterator->second--;
9686 LocationNameMultiMapIterator++)
9688 if(LocationNameMultiMapIterator->second >= 0)
9694 if(LocationNameMultiMapIterator->second < -(
int)(VecPos + 1))
9696 LocationNameMultiMapIterator->second++;
9700 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9706 if(TkEl.
Conn[0] ==
int(VecPos))
9711 if(TkEl.
Conn[0] >
int(VecPos))
9715 if(TkEl.
Conn[0] > -1)
9743 for(
unsigned int TVPos = 0; TVPos <
TrackVector.size(); TVPos++)
9749 LocationNameEntry.second = -1 - TVPos;
9760 LocationNameEntry.second = ITVPos;
9802 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9834 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9862 AnsiString((
short)FirstTrack));
9863 bool LengthDifferent =
false, SpeedDifferent =
false;
9870 int EXArray[16][2] =
9872 {2, 4}, {6, 2}, {8, 6}, {4, 8},
9873 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
9876 int Index = -1, BrNum = -1, GrNum = -1, InLink, OutLink;
9877 Graphics::TBitmap *Bitmap;
9881 InLink = TrackElement.
Link[0];
9882 OutLink = TrackElement.
Link[1];
9886 InLink = TrackElement.
Link[2];
9887 OutLink = TrackElement.
Link[3];
9889 for(
int x = 0; x < 16; x++)
9891 if((InLink == EXArray[x][0] && OutLink == EXArray[x][1]) || (InLink == EXArray[x][1] && OutLink == EXArray[x][0]))
9898 throw Exception(
"Error, failed to find Index in TTrack::MarkOneLength");
9917 else if(TrackElement.
SpeedTag == 54)
9921 else if(TrackElement.
SpeedTag == 55)
9932 else if(TrackElement.
SpeedTag == 58)
9936 else if(TrackElement.
SpeedTag == 59)
9941 else if(Index == 14)
9947 else if(TrackElement.
SpeedTag == 52)
9951 else if(TrackElement.
SpeedTag == 57)
9956 else if(Index == 15)
9962 else if(TrackElement.
SpeedTag == 53)
9966 else if(TrackElement.
SpeedTag == 56)
9980 if(LengthDifferent && SpeedDifferent)
10048 else if(LengthDifferent && !SpeedDifferent)
10195 AnsiString((
short)FirstTrack));
10196 LengthDifferent =
false;
10197 SpeedDifferent =
false;
10202 LengthDifferent =
true;
10206 SpeedDifferent =
true;
10208 if(LengthDifferent || SpeedDifferent)
10221 LengthDifferent =
true;
10225 SpeedDifferent =
true;
10227 if(LengthDifferent || SpeedDifferent)
10240 LengthDifferent =
true;
10244 SpeedDifferent =
true;
10246 if(LengthDifferent || SpeedDifferent)
10326 AnsiString TempName;
10327 int VecPos, StartVecPos, Count, EntryPos, StartEntryPos, ForwardNumber, ReverseNumber;
10328 bool ForwardSet, ReverseSet;
10330 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10335 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10340 ForwardSet =
false;
10341 ReverseSet =
false;
10375 for(
int y = 0; y < 2; y++)
10406 StartElement = TempElement;
10407 StartVecPos = VecPos;
10410 EntryPos = 1 - Dir;
10411 StartEntryPos = 1 - Dir;
10419 VecPos = TempElement.
Conn[1 - EntryPos];
10420 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
10422 EntryPos = TempEntryPos;
10443 ForwardNumber = ((Count + 1) / 2) + 1;
10444 ReverseNumber = (Count - ForwardNumber) + 1;
10446 EntryPos = 1 - Dir;
10447 TempElement = StartElement;
10448 VecPos = StartVecPos;
10449 if(Count == ForwardNumber)
10454 if(Count == ReverseNumber)
10462 VecPos = TempElement.
Conn[1 - EntryPos];
10463 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
10465 EntryPos = TempEntryPos;
10467 if(Count == ForwardNumber)
10472 if(Count == ReverseNumber)
10485 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10514 AnsiString TempName;
10515 std::list<unsigned int> NameList;
10516 std::list<AnsiString> ContinuationNameList;
10517 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10523 ContinuationNameList.push_back(
TrackElementAt(1597, x).ActiveTrackElementName);
10526 ContinuationNameList.sort();
10527 ContinuationNameList.unique();
10529 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10534 bool NameIsAContinuation =
false;
10535 if(std::find(ContinuationNameList.begin(), ContinuationNameList.end(), TempElement.
ActiveTrackElementName) != ContinuationNameList.end())
10537 NameIsAContinuation =
true;
10550 if(((TempElement.
Conn[2] > -1)) && (TempElement.
Conn[3] > -1) &&
10558 NameList.push_back(x);
10563 if((TempElement.
Conn[2] > -1) && (TempElement.
Conn[3] > -1) &&
10571 NameList.push_back(x);
10581 NameList.push_back(x);
10584 while(!NameList.empty())
10586 unsigned int a = NameList.front();
10587 NameList.pop_front();
10745 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10801 if((TextH / 16) - 1 <
HLocMin)
10805 if((TextH / 16) + 1 >
HLocMax)
10809 if((TextV / 16) - 1 <
VLocMin)
10813 if((TextV / 16) + 1 >
VLocMax)
10843 void TTrack::UserGraphicMove(
int Caller,
int HPosInput,
int VPosInput,
int &UserGraphicItem,
int &UserGraphicMoveHPos,
int &UserGraphicMoveVPos,
10844 bool &UserGraphicFoundFlag)
10847 TUserGraphicVector::iterator UserGraphicPtr;
10849 UserGraphicFoundFlag =
false;
10856 if((HPosInput >= (*UserGraphicPtr).HPos) && (HPosInput < ((*UserGraphicPtr).HPos + (*UserGraphicPtr).Width)) && (VPosInput >=
10857 (*UserGraphicPtr).VPos) && (VPosInput < ((*UserGraphicPtr).VPos + (*UserGraphicPtr).Height)))
10859 UserGraphicItem = x;
10860 UserGraphicMoveHPos = (*UserGraphicPtr).HPos;
10861 UserGraphicMoveVPos = (*UserGraphicPtr).VPos;
10862 UserGraphicFoundFlag =
true;
10880 int SpeedTag = TrackElement.
SpeedTag;
10884 throw Exception(
"Error - SpeedTag value " + AnsiString(SpeedTag) +
" in RetrieveStripedNamedLocationGraphicsWhereRelevant");
10933 return(GraphicOutput);
10941 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
10944 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in TrackElementAt");
10957 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
InactiveTrackVector.size()) +
", At: " + AnsiString(At) +
10958 " in InactiveTrackElementAt");
10969 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
10971 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in BlankElementAt");
10996 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
10997 int FirstNamedExitPos, SecondNamedExitPos, FirstNamedLinkedExitPos, SecondNamedLinkedEntryPos;
11001 if(SNRange.first == SNRange.second)
11006 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
11008 if(SNIterator->second < 0)
11022 HVPair.first = InactiveElement.
HLoc;
11023 HVPair.second = InactiveElement.
VLoc;
11027 (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in OneStationLongEnoughForSplit (1)");
11029 int TVPos =
TrackMap.find(HVPair)->second;
11032 if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
11038 FirstNamedExitPos = 0;
11040 SecondNamedElement =
TrackElementAt(561, FirstNamedElement.
Conn[FirstNamedExitPos]);
11042 FirstNamedLinkedElement =
TrackElementAt(562, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
11043 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
11046 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
11048 SecondNamedLinkedElement =
TrackElementAt(563, SecondNamedElement.
Conn[SecondNamedExitPos]);
11049 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
11050 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
11053 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
11063 FirstNamedExitPos = 1;
11065 SecondNamedElement =
TrackElementAt(564, FirstNamedElement.
Conn[FirstNamedExitPos]);
11067 FirstNamedLinkedElement =
TrackElementAt(565, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
11068 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
11071 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
11073 SecondNamedLinkedElement =
TrackElementAt(566, SecondNamedElement.
Conn[SecondNamedExitPos]);
11074 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
11075 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
11078 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
11104 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
11105 int FirstNamedExitPos, SecondNamedEntryPos, SecondNamedExitPos;
11109 if(SNRange.first == SNRange.second)
11114 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
11116 if(SNIterator->second < 0)
11130 HVPair.first = InactiveElement.
HLoc;
11131 HVPair.second = InactiveElement.
VLoc;
11134 throw Exception (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in OneNonStationLongEnoughForSplit(1)");
11136 int TVPos =
TrackMap.find(HVPair)->second;
11139 if(((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1)) && ((FirstNamedElement.
Conn[2] == -1) || (FirstNamedElement.
Conn[3] == -1)))
11144 if((FirstNamedElement.
Conn[2] == -1) || (FirstNamedElement.
Conn[3] == -1))
11146 FirstNamedExitPos = 0;
11148 SecondNamedElement =
TrackElementAt(1611, FirstNamedElement.
Conn[FirstNamedExitPos]);
11151 SecondNamedEntryPos = FirstNamedElement.
ConnLinkPos[FirstNamedExitPos];
11152 if((SecondNamedEntryPos == 0) || (SecondNamedEntryPos == 1))
11154 SecondNamedExitPos = 1 - SecondNamedEntryPos;
11156 else if(SecondNamedEntryPos == 2)
11158 SecondNamedExitPos = 3;
11160 else if(SecondNamedEntryPos == 3)
11162 SecondNamedExitPos = 2;
11164 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
11171 FirstNamedExitPos = 1;
11173 SecondNamedElement =
TrackElementAt(1612, FirstNamedElement.
Conn[FirstNamedExitPos]);
11176 SecondNamedEntryPos = FirstNamedElement.
ConnLinkPos[FirstNamedExitPos];
11177 if((SecondNamedEntryPos == 0) || (SecondNamedEntryPos == 1))
11179 SecondNamedExitPos = 1 - SecondNamedEntryPos;
11181 else if(SecondNamedEntryPos == 2)
11183 SecondNamedExitPos = 3;
11185 else if(SecondNamedEntryPos == 3)
11187 SecondNamedExitPos = 2;
11189 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
11197 else if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
11199 FirstNamedExitPos = 2;
11201 SecondNamedElement =
TrackElementAt(1613, FirstNamedElement.
Conn[FirstNamedExitPos]);
11204 SecondNamedEntryPos = FirstNamedElement.
ConnLinkPos[FirstNamedExitPos];
11205 if((SecondNamedEntryPos == 0) || (SecondNamedEntryPos == 1))
11207 SecondNamedExitPos = 1 - SecondNamedEntryPos;
11209 else if(SecondNamedEntryPos == 2)
11211 SecondNamedExitPos = 3;
11213 else if(SecondNamedEntryPos == 3)
11215 SecondNamedExitPos = 2;
11217 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
11224 FirstNamedExitPos = 3;
11226 SecondNamedElement =
TrackElementAt(1614, FirstNamedElement.
Conn[FirstNamedExitPos]);
11229 SecondNamedEntryPos = FirstNamedElement.
ConnLinkPos[FirstNamedExitPos];
11230 if((SecondNamedEntryPos == 0) || (SecondNamedEntryPos == 1))
11232 SecondNamedExitPos = 1 - SecondNamedEntryPos;
11234 else if(SecondNamedEntryPos == 2)
11236 SecondNamedExitPos = 3;
11238 else if(SecondNamedEntryPos == 3)
11240 SecondNamedExitPos = 2;
11242 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
11259 int MidEntryPos,
int &FrontTrainFrontPos,
int &FrontTrainRearPos,
int &RearTrainFrontPos,
int &RearTrainRearPos,
bool &TemporaryDelay)
11267 LocationName + AnsiString(LeadElement) +
"," + AnsiString(LeadExitPos) +
"," + AnsiString(MidElement) +
"," + AnsiString(MidEntryPos));
11269 TemporaryDelay =
false;
11271 int FwdPos[3] = {LeadElement, -1, -1};
11272 int RwdPos[3] = {MidElement, -1, -1};
11275 int FwdPos1EntryPos, FwdPos1ExitPos, FwdPos2EntryPos, FwdPos2ExitPos, RwdPos1EntryPos, RwdPos1ExitPos, RwdPos2EntryPos, RwdPos2ExitPos;
11277 bool FwdDerail1 =
false, FwdDerail2 =
false, RwdDerail1 =
false, RwdDerail2 =
false;
11278 int NumFwdNamedElements = 0, NumFwdElements = 0, NumRwdNamedElements = 0, NumRwdElements = 1;
11281 NumRwdNamedElements = 1;
11284 FwdPos[1] = FwdPos0Element.
Conn[LeadExitPos];
11287 NumFwdElements = 1;
11291 NumFwdNamedElements = 1;
11293 FwdPos1EntryPos = FwdPos0Element.
ConnLinkPos[LeadExitPos];
11295 FwdPos[2] = FwdPos1Element.
Conn[FwdPos1ExitPos];
11298 NumFwdElements = 2;
11299 FwdPos2EntryPos = FwdPos1Element.
ConnLinkPos[FwdPos1ExitPos];
11304 NumFwdNamedElements = 2;
11310 RwdPos[1] = RwdPos0Element.
Conn[MidEntryPos];
11313 NumRwdElements = 2;
11317 NumRwdNamedElements = 2;
11319 RwdPos1ExitPos = RwdPos0Element.
ConnLinkPos[MidEntryPos];
11321 RwdPos[2] = RwdPos1Element.
Conn[RwdPos1EntryPos];
11324 NumRwdElements = 3;
11325 RwdPos2ExitPos = RwdPos1Element.
ConnLinkPos[RwdPos1EntryPos];
11330 NumRwdNamedElements = 3;
11337 if(NumFwdNamedElements == 2)
11339 FrontTrainFrontPos = FwdPos[2];
11340 FrontTrainRearPos = FwdPos[1];
11341 RearTrainFrontPos = LeadElement;
11342 RearTrainRearPos = MidElement;
11343 if(FwdDerail1 || FwdDerail2)
11345 TrainController->
StopTTClockMessage(159, HeadCode +
" unable to split at " + LocationName +
", points set wrongly ahead of train. Please change these points to allow the split.");
11346 TemporaryDelay =
true;
11352 TrainController->
StopTTClockMessage(160, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing ahead of this train. Please move the obstructing train to allow the split.");
11353 TemporaryDelay =
true;
11359 TrainController->
StopTTClockMessage(161, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing ahead of this train. Please move the obstructing train to allow the split.");
11360 TemporaryDelay =
true;
11368 else if((NumFwdNamedElements == 1) && (NumRwdNamedElements >= 1) && (NumRwdElements >= 2))
11370 FrontTrainFrontPos = FwdPos[1];
11371 FrontTrainRearPos = LeadElement;
11372 RearTrainFrontPos = MidElement;
11373 RearTrainRearPos = RwdPos[1];
11376 TrainController->
StopTTClockMessage(162, HeadCode +
" unable to split at " + LocationName +
", points set wrongly ahead of train. Please change these points to allow the split.");
11377 TemporaryDelay =
true;
11383 TrainController->
StopTTClockMessage(163, HeadCode +
" unable to split at " + LocationName +
", points set wrongly behind train. Please change these points to allow the split.");
11384 TemporaryDelay =
true;
11390 TrainController->
StopTTClockMessage(164, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing ahead of this train. Please move the obstructing train to allow the split.");
11391 TemporaryDelay =
true;
11397 TrainController->
StopTTClockMessage(165, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing behind this train. Please move the obstructing train to allow the split.");
11398 TemporaryDelay =
true;
11406 else if((NumRwdNamedElements >= 2) && (NumRwdElements == 3))
11408 FrontTrainFrontPos = LeadElement;
11409 FrontTrainRearPos = MidElement;
11410 RearTrainFrontPos = RwdPos[1];
11411 RearTrainRearPos = RwdPos[2];
11412 if(RwdDerail1 || RwdDerail2)
11414 TrainController->
StopTTClockMessage(166, HeadCode +
" unable to split at " + LocationName +
", points set wrongly behind train. Please change these points to allow the split.");
11415 TemporaryDelay =
true;
11421 TrainController->
StopTTClockMessage(167, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing behind this train. Please move the obstructing train to allow the split.");
11422 TemporaryDelay =
true;
11428 TrainController->
StopTTClockMessage(168, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing behind this train. Please move the obstructing train to allow the split.");
11429 TemporaryDelay =
true;
11438 else if((NumFwdNamedElements == 1) && (NumFwdElements == 2))
11440 FrontTrainFrontPos = FwdPos[2];
11441 FrontTrainRearPos = FwdPos[1];
11442 RearTrainFrontPos = LeadElement;
11443 RearTrainRearPos = MidElement;
11444 if(FwdDerail1 || FwdDerail2)
11446 TrainController->
StopTTClockMessage(169, HeadCode +
" unable to split at " + LocationName +
", points set wrongly ahead of train. Please change these points to allow the split.");
11447 TemporaryDelay =
true;
11453 TrainController->
StopTTClockMessage(170, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing ahead of this train. Please move the obstructing train to allow the split.");
11454 TemporaryDelay =
true;
11460 TrainController->
StopTTClockMessage(171, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing ahead of this train. Please move the obstructing train to allow the split.");
11461 TemporaryDelay =
true;
11469 else if((NumFwdElements >= 1) && (NumRwdNamedElements >= 1) && (NumRwdElements >= 2))
11471 FrontTrainFrontPos = FwdPos[1];
11472 FrontTrainRearPos = LeadElement;
11473 RearTrainFrontPos = MidElement;
11474 RearTrainRearPos = RwdPos[1];
11477 TrainController->
StopTTClockMessage(172, HeadCode +
" unable to split at " + LocationName +
", points set wrongly ahead of train. Please change these points to allow the split.");
11478 TemporaryDelay =
true;
11484 TrainController->
StopTTClockMessage(173, HeadCode +
" unable to split at " + LocationName +
", points set wrongly behind train. Please change these points to allow the split.");
11485 TemporaryDelay =
true;
11491 TrainController->
StopTTClockMessage(174, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing ahead of this train. Please move the obstructing train to allow the split.");
11492 TemporaryDelay =
true;
11498 TrainController->
StopTTClockMessage(175, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing behind this train. Please move the obstructing train to allow the split.");
11499 TemporaryDelay =
true;
11519 if(SNRange.first != SNRange.second)
11521 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
11523 if(SNIterator->second < 0)
11545 "," + AnsiString(SpeedTag));
11556 throw Exception(
"Error, FoundFlag false in PlatformOnSignalSide after IsPlatformOrNamedNonStationLocationPresent called successfully");
11586 else if(SpeedTag == 69)
11612 else if(SpeedTag == 70)
11638 else if(SpeedTag == 71)
11675 AnsiString(LinkPos) +
"," + AnsiString(OwnTrainID));
11676 if((LinkPos < 0) || (TrackPos < 0))
11708 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in SelectVectorAt");
11720 AnsiString(VLocIn) +
"," + AnsiString(LinkIn));
11721 bool FoundFlag =
false;
11736 int VLocHi = -2000000000, VLocLo = 2000000000, HLoc = 2000000000;
11737 bool FoundFlag =
false;
11762 VPosHi = 16 * VLocHi;
11763 VPosLo = 16 * VLocLo;
11782 AnsiString(EndTVPosition));
11793 int Link0Squares = ((EndElement.
HLoc - NewHLocLink0) * (EndElement.
HLoc - NewHLocLink0)) +
11794 ((EndElement.
VLoc - NewVLocLink0) * (EndElement.
VLoc - NewVLocLink0));
11795 int Link1Squares = ((EndElement.
HLoc - NewHLocLink1) * (EndElement.
HLoc - NewHLocLink1)) +
11796 ((EndElement.
VLoc - NewVLocLink1) * (EndElement.
VLoc - NewVLocLink1));
11798 if(Link0Squares <= Link1Squares)
11816 AnsiString(LinkPos));
11835 if((LinkPos == 1) && (TE.
Attribute == 0))
11840 else if(LinkPos == 1)
11846 else if((LinkPos == 3) && (TE.
Attribute == 1))
11851 else if(LinkPos == 3)
11858 else if(LinkPos == 0)
11863 else if(LinkPos == 1)
11868 else if(LinkPos == 2)
11873 else if(LinkPos == 3)
11878 throw Exception(
"Error, failure in GetExitPos");
11927 if((TE.
Link[0] == Link) || (TE.
Link[1] == Link))
11931 else if((TE.
Link[2] == Link) || (TE.
Link[3] == Link))
11973 "," + AnsiString(DiagonalLinkNumber));
11978 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(8, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
TrainOnLink(9, HLoc - 1, VLoc, 9, TrainID)))
11983 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(10, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
TrainOnLink(11, HLoc, VLoc - 1, 9, TrainID)))
11988 if(((DiagonalLinkNumber == 3) &&
TrainOnLink(12, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(13, HLoc + 1, VLoc, 7, TrainID)))
11993 if(((DiagonalLinkNumber == 7) &&
TrainOnLink(14, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(15, HLoc, VLoc + 1, 3, TrainID)))
12009 AnsiString JustFileName =
"";
12014 int LastDelim = UGI.
FileName.LastDelimiter(
'\\');
12021 JustFileName = UGI.
FileName.SubString(LastDelim + 1, UGI.
FileName.Length() - LastDelim);
12040 typedef std::list<int> TNamePosList;
12041 TNamePosList NamePosList;
12042 typedef TNamePosList::iterator TNPLIt;
12044 typedef std::list<int> TOnePlatList;
12045 TOnePlatList OnePlatList;
12046 typedef TOnePlatList::iterator TOPLIt;
12049 NamePosList.clear();
12050 OnePlatList.clear();
12051 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
12053 if(
TrackElementAt(988, x).ActiveTrackElementName == LocationName)
12055 NamePosList.push_back(x);
12060 if(!NamePosList.empty())
12062 OnePlatList.push_back(NamePosList.back());
12063 NamePosList.pop_back();
12065 while(!OnePlatList.empty())
12067 TempInt = OnePlatList.front();
12070 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[0]);
12071 if(NPLIt != NamePosList.end() && ((TempElement.
Link[0] == 2) || (TempElement.
Link[0] == 4) || (TempElement.
Link[0] == 6) || (TempElement.
Link[0] == 8)))
12073 OnePlatList.push_back(TempElement.
Conn[0]);
12074 NamePosList.erase(NPLIt);
12076 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[1]);
12077 if(NPLIt != NamePosList.end() && ((TempElement.
Link[1] == 2) || (TempElement.
Link[1] == 4) || (TempElement.
Link[1] == 6) || (TempElement.
Link[1] == 8)))
12079 OnePlatList.push_back(TempElement.
Conn[1]);
12080 NamePosList.erase(NPLIt);
12083 OnePlatList.erase(OnePlatList.begin());
12084 if(OnePlatList.empty())
12087 if(!NamePosList.empty())
12089 OnePlatList.push_back(NamePosList.back());
12090 NamePosList.pop_back();
12106 throw Exception(
"Element at " + AnsiString(FPVIt->TVPos) +
" not signal in RepairFailedSignals");
12110 throw Exception(
"Signals not failed at " + AnsiString(FPVIt->TVPos) +
" in RepairFailedSignals");
12138 throw Exception(
"Element at " + AnsiString(FPVIt->TVPos) +
" not points in RepairFailedPoints");
12142 throw Exception(
"Points not failed at " + AnsiString(FPVIt->TVPos) +
" in RepairFailedPoints");
12168 throw Exception(
"Element at " + AnsiString(FPVIt->TVPos) +
" not simple in RepairFailedPoints");
12172 throw Exception(
"No TSR at " + AnsiString(FPVIt->TVPos) +
" in RepairTSR");
12194 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
12213 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
UserGraphicVector.size()) +
", At: " + AnsiString(At) +
" in UserGraphicVectorAt");
12228 throw Exception(
"Return value negative in call to LastElementNumber");
12240 throw Exception(
"PrefDirVector empty in call to LastElementPtr");
12254 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedPrefDirElementAt");
12266 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
12267 " in GetModifiablePrefDirElementAt");
12277 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
12279 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedSearchElementAt");
12289 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
12291 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableSearchElementAt");
12308 int TrackVectorPosition;
12359 FinishElement =
false;
12360 int TrackVectorPosition;
12382 if(TrackElement.
HLoc >= StartPrefDirElement.
HLoc)
12392 if(TrackElement.
VLoc >= StartPrefDirElement.
VLoc)
12415 for(
int x = 0; x < 4; x++)
12438 FinishElement =
true;
12446 for(
int x = 0; x < 4; x++)
12458 FinishElement =
true;
12466 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
12473 .ELinkPos] ==
Lead))
12489 FinishElement =
true;
12508 FinishElement =
true;
12527 FinishElement =
true;
12542 FinishElement =
true;
12551 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
12567 FinishElement =
true;
12573 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
12596 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition));
12597 int VectorCount = 0;
12601 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
12603 for(
int x = 0; x < VectorCount; x++)
12610 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
12614 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
12615 SearchElement.
ELinkPos = NextELinkPos;
12636 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
12638 SearchElement.
XLinkPos = NextXLinkPos;
12664 for(
int x = 0; x < VectorCount; x++)
12676 for(
int x = 0; x < VectorCount; x++)
12690 for(
int x = 0; x < VectorCount; x++)
12704 for(
int x = 0; x < VectorCount; x++)
12714 for(
int x = 0; x < VectorCount; x++)
12725 SearchElement.
XLink = SearchElement.
Link[1];
12744 SearchElement.
XLink = SearchElement.
Link[3];
12757 for(
int x = 0; x < VectorCount; x++)
12772 XLinkPos = NextXLinkPos;
12773 CurrentTrackElement = SearchElement;
12792 throw Exception(
"Error, SearchVector empty");
12799 for(
int x = 0; x < 4; x++)
12852 throw Exception(
"Error in EntryExitNumber 1");
12871 if(PrefDirElement.
XLink == -1)
12883 if(PrefDirElement.
XLink != -1)
12887 throw Exception(
"Error in EntryExitNumber 2");
12925 LeadingPoints =
false;
12953 LeadingPoints =
true;
12969 AnsiString ErrorString;
12970 bool Error =
false;
12977 ErrorString =
"HLoc";
12983 ErrorString =
"VLoc";
12989 ErrorString =
"ELink";
12995 ErrorString =
"ELinkPos";
13001 ErrorString =
"XLink";
13007 ErrorString =
"XLinkPos";
13013 ErrorString =
"Tag";
13019 ErrorString =
"TrackVectorPosition";
13025 ErrorString =
"EXNumber";
13032 ErrorString =
"CheckCount";
13039 ErrorString =
"EntryGraphicPtr";
13045 ErrorString =
"EntryDirectionGraphicPtr";
13054 ErrorString =
"Last XLink not connected to this element";
13061 throw Exception(
"Error at " + AnsiString(Position) +
" " + ErrorString);
13085 for(
int PrefDirVecPos = (
PrefDirVector.size() - 1); PrefDirVecPos >= (int)x; PrefDirVecPos--)
13142 AnsiString((
short)BuildingPrefDir));
13145 if(PrefDirSize() == 0)
13150 for(
unsigned int x = 0; x < PrefDirSize(); x++)
13162 Disp->PlotOutput(12, (TempPrefDirElement.
HLoc * 16), (TempPrefDirElement.
VLoc * 16), TempPrefDirElement.
EXGraphicPtr);
13174 if(x == (PrefDirSize() - 1))
13183 if((PrefDirRoute ==
PrefDirCall) && BuildingPrefDir)
13185 HPos = GetFixedPrefDirElementAt(4, 0).
HLoc * 16;
13186 VPos = GetFixedPrefDirElementAt(5, 0).VLoc * 16;
13187 Disp->Rectangle(1, HPos, VPos,
clB0G0R5, 2, 2);
13189 if(PrefDirSize() > 1)
13191 unsigned int LatestPos = PrefDirSize() - 1;
13192 HPos = GetFixedPrefDirElementAt(6, LatestPos).HLoc * 16;
13193 VPos = GetFixedPrefDirElementAt(7, LatestPos).VLoc * 16;
13194 Disp->Rectangle(2, HPos, VPos,
clB5G0R0, 4, 2);
13215 int H, V, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
13218 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
13222 H = MMIT->first.first;
13223 V = MMIT->first.second;
13226 if(PrefDirPos0 > -1)
13230 if(PrefDirPos1 > -1)
13234 if(PrefDirPos2 > -1)
13238 if(PrefDirPos3 > -1)
13242 if(PrefDirPos3 > -1)
13258 else if(PrefDirPos2 > -1)
13300 else if(PrefDirPos1 > -1)
13323 else if(PrefDirPos0 > -1)
13342 int NumberOfPrefDirElements = 0;
13345 for(
int x = 0; x < NumberOfPrefDirElements; x++)
13347 VecFile >> TempInt;
13350 VecFile >> TempInt;
13351 LoadPrefDirElement.
ELink = TempInt;
13352 VecFile >> TempInt;
13353 LoadPrefDirElement.
ELinkPos = TempInt;
13354 VecFile >> TempInt;
13355 LoadPrefDirElement.
XLink = TempInt;
13356 VecFile >> TempInt;
13357 LoadPrefDirElement.
XLinkPos = TempInt;
13358 VecFile >> TempInt;
13359 LoadPrefDirElement.
EXNumber = TempInt;
13360 VecFile >> TempInt;
13365 if(!(LoadPrefDirElement.
IsARoute))
13391 int NumberOfPrefDirElements = 0;
13394 for(
int x = 0; x < NumberOfPrefDirElements; x++)
13396 VecFile >> TempInt;
13397 VecFile >> TempInt;
13400 VecFile >> TempInt;
13401 LoadPrefDirElement.
ELink = TempInt;
13402 VecFile >> TempInt;
13403 LoadPrefDirElement.
ELinkPos = TempInt;
13404 VecFile >> TempInt;
13405 LoadPrefDirElement.
XLink = TempInt;
13406 VecFile >> TempInt;
13407 LoadPrefDirElement.
XLinkPos = TempInt;
13408 VecFile >> TempInt;
13409 LoadPrefDirElement.
EXNumber = TempInt;
13410 VecFile >> TempInt;
13415 if(!(LoadPrefDirElement.
IsARoute))
13443 int NumberOfPrefDirElements = 0;
13446 if((NumberOfPrefDirElements < 0) || (NumberOfPrefDirElements > 1000000))
13451 for(
int x = 0; x < NumberOfPrefDirElements; x++)
13458 VecFile >> TempInt;
13459 if((TempInt < 0) || (TempInt >= NumberOfActiveElements))
13464 VecFile >> TempInt;
13465 if((TempInt < -1) || (TempInt > 9))
13470 VecFile >> TempInt;
13471 if((TempInt < -1) || (TempInt > 3))
13476 VecFile >> TempInt;
13477 if((TempInt < -1) || (TempInt > 9))
13482 VecFile >> TempInt;
13483 if((TempInt < -1) || (TempInt > 3))
13488 VecFile >> TempInt;
13489 if((TempInt < -1) || (TempInt > 27))
13494 VecFile >> TempInt;
13502 VecFile >> TempInt;
13503 if((TempInt != 0) && (TempInt != 1))
13508 VecFile >> TempInt;
13509 if((TempInt != 0) && (TempInt != 1))
13514 VecFile >> TempInt;
13515 if((TempInt != 0) && (TempInt != 1))
13538 for(
int y = 0; y < NumberOfPrefDirElements; y++)
13540 VecFile << y <<
'\n';
13541 VecFile <<
PrefDirVector.at(y).TrackVectorPosition <<
'\n';
13551 if(y == (NumberOfPrefDirElements - 1))
13553 VecFile <<
"************" <<
'\0' <<
'\n';
13557 VecFile <<
"******" <<
'\0' <<
'\n';
13571 for(
int y = 0; y < NumberOfSearchElements; y++)
13573 VecFile << y <<
'\n';
13574 VecFile <<
SearchVector.at(y).TrackVectorPosition <<
'\n';
13584 if(y == (NumberOfSearchElements - 1))
13586 VecFile <<
"************" <<
'\0' <<
'\n';
13590 VecFile <<
"******" <<
'\0' <<
'\n';
13703 bool AlreadyPresent, FoundFlag;
13704 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
13706 for(
unsigned int x = 0; x < InputPrefDir->
PrefDirSize(); x++)
13710 AlreadyPresent =
false;
13715 AlreadyPresent =
true;
13719 AlreadyPresent =
true;
13723 AlreadyPresent =
true;
13727 AlreadyPresent =
true;
13730 if(!AlreadyPresent)
13777 for(
unsigned int z = 0; z < 4; z++)
13785 throw Exception(
"Error in RebuildPrefDirVector - PrefDirVector is unsafe");
13799 bool DiscrepancyFound =
false;
13810 DiscrepancyFound =
true;
13815 DiscrepancyFound =
true;
13820 DiscrepancyFound =
true;
13825 DiscrepancyFound =
true;
13830 DiscrepancyFound =
true;
13836 DiscrepancyFound =
true;
13839 if(DiscrepancyFound)
13841 ShowMessage(
"Discrepancies found in the preferred direction file, preferred directions will be cleared");
13856 bool DiscrepancyFound =
false;
13867 DiscrepancyFound =
true;
13871 DiscrepancyFound =
true;
13876 DiscrepancyFound =
true;
13881 DiscrepancyFound =
true;
13886 DiscrepancyFound =
true;
13892 DiscrepancyFound =
true;
13896 return(!DiscrepancyFound);
13908 bool FoundFlag =
false;
13909 int PrefDir0, PrefDir1, PrefDir2, PrefDir3;
13917 throw Exception(
"CheckPrefDir4MultiMap Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
13918 " in PrefDir4MultiMap, Caller=" + (AnsiString)Caller);
13920 if((PrefDir0 != (
int)a) && (PrefDir1 != (
int)a) && (PrefDir2 != (
int)a) && (PrefDir3 != (
int)a))
13922 throw Exception(
"CheckPrefDir4MultiMap Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
13923 (AnsiString)CheckElement.
VLoc +
" Map values=" + (AnsiString)PrefDir0 +
", " + (AnsiString)PrefDir1 +
", " + (AnsiString)PrefDir2 +
", " +
13924 (AnsiString)PrefDir3 +
" PrefDirVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
13929 throw Exception(
"CheckPrefDir4MultiMap Error - Map Size=" + (AnsiString)
PrefDirVector.size() +
" PrefDirVectorSize=" + (AnsiString)
PrefDirVector.size()
13930 +
" Caller=" + (AnsiString)Caller);
13956 PrefDirMapKeyPair.first = HLoc;
13957 PrefDirMapKeyPair.second = VLoc;
13958 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
13961 if(ItPair.first == ItPair.second)
13969 PrefDirPos0 = ItPair.first->second;
13971 if(ItPair.first == ItPair.second)
13976 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
13978 PrefDirPos1 = ItPair.first->second;
13981 if(ItPair.first == ItPair.second)
13986 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
13988 PrefDirPos2 = ItPair.first->second;
13991 if(ItPair.first == ItPair.second)
13996 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
13998 PrefDirPos3 = ItPair.first->second;
14013 +
"," + AnsiString(LinkNumberPos));
14015 int PD0, PD1, PD2, PD3;
14016 if(
PrefDirVector.at(PrefDirVectorNumber).Conn[LinkNumberPos] > -1)
14020 PD0, PD1, PD2, PD3);
14032 LinkedPrefDirVectorNumber = PD0;
14041 LinkedPrefDirVectorNumber = PD1;
14051 LinkedPrefDirVectorNumber = PD0;
14060 LinkedPrefDirVectorNumber = PD1;
14069 LinkedPrefDirVectorNumber = PD2;
14078 LinkedPrefDirVectorNumber = PD3;
14083 LinkedPrefDirVectorNumber = -1;
14089 LinkedPrefDirVectorNumber = -1;
14094 catch(
const Exception &e)
14096 LinkedPrefDirVectorNumber = -1;
14111 +
"," + AnsiString(LinkNumberPos));
14113 int PD0, PD1, PD2, PD3;
14114 if(
PrefDirVector.at(PrefDirVectorNumber).Conn[LinkNumberPos] > -1)
14118 PD0, PD1, PD2, PD3);
14131 LinkedPrefDirVectorNumber = PD0;
14141 LinkedPrefDirVectorNumber = PD1;
14146 LinkedPrefDirVectorNumber = -1;
14154 LinkedPrefDirVectorNumber = PD0;
14163 LinkedPrefDirVectorNumber = PD1;
14172 LinkedPrefDirVectorNumber = PD2;
14181 LinkedPrefDirVectorNumber = PD3;
14186 LinkedPrefDirVectorNumber = -1;
14192 LinkedPrefDirVectorNumber = -1;
14197 catch(
const Exception &e)
14199 LinkedPrefDirVectorNumber = -1;
14211 int PD0, PD1, PD2, PD3;
14263 THVPair PrefDir4MultiMapKeyPair;
14266 PrefDir4MultiMapKeyPair.first = LoadPrefDirElement.
HLoc;
14267 PrefDir4MultiMapKeyPair.second = LoadPrefDirElement.
VLoc;
14268 PrefDir4MultiMapEntry.first = PrefDir4MultiMapKeyPair;
14291 throw Exception(
"Failed to find PrefDir4MultiMap erase element");
14310 AnsiString(ErasedElementNumber));
14315 if(MapPtr->second > ErasedElementNumber)
14337 throw Exception(
"PrefDirVectorPosition out of range");
14340 THVPair PrefDir4MultiMapKeyPair;
14342 PrefDir4MultiMapKeyPair.first = PrefDirElement.
HLoc;
14343 PrefDir4MultiMapKeyPair.second = PrefDirElement.
VLoc;
14344 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
14347 if(ItPair.first == ItPair.second)
14350 return(ItPair.first);
14354 if(ItPair.first->second == PrefDirVectorPosition)
14358 return(ItPair.first);
14361 if(ItPair.first == ItPair.second)
14364 return(ItPair.first);
14366 if(ItPair.first->second == PrefDirVectorPosition)
14370 return(ItPair.first);
14373 if(ItPair.first == ItPair.second)
14376 return(ItPair.first);
14378 if(ItPair.first->second == PrefDirVectorPosition)
14382 return(ItPair.first);
14385 if(ItPair.first == ItPair.second)
14388 return(ItPair.first);
14390 if(ItPair.first->second == PrefDirVectorPosition)
14394 return(ItPair.first);
14398 return(ItPair.first);
14411 THVPair PrefDir4MultiMapKeyPair;
14413 PrefDir4MultiMapKeyPair.first = HLoc;
14414 PrefDir4MultiMapKeyPair.second = VLoc;
14415 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
14418 if(ItPair.first == ItPair.second)
14426 return(ItPair.first->second);
14435 bool ErasedFlag =
false;
14437 if(ErasedTrackVectorPosition > -1)
14446 ErasedFlag =
false;
14448 if(
PrefDirVector.at(x).TrackVectorPosition == ErasedTrackVectorPosition)
14453 else if(
PrefDirVector.at(x).Conn[0] == ErasedTrackVectorPosition)
14458 else if(
PrefDirVector.at(x).Conn[1] == ErasedTrackVectorPosition)
14463 else if(
PrefDirVector.at(x).Conn[2] == ErasedTrackVectorPosition)
14468 else if(
PrefDirVector.at(x).Conn[3] == ErasedTrackVectorPosition)
14476 if(
PrefDirVector.at(x).TrackVectorPosition > ErasedTrackVectorPosition)
14480 if(
PrefDirVector.at(x).Conn[0] > ErasedTrackVectorPosition)
14484 if(
PrefDirVector.at(x).Conn[1] > ErasedTrackVectorPosition)
14488 if(
PrefDirVector.at(x).Conn[2] > ErasedTrackVectorPosition)
14492 if(
PrefDirVector.at(x).Conn[3] > ErasedTrackVectorPosition)
14507 OverallDistance = 0;
14508 OverallSpeedLimit = 0;
14509 LeadingPointsAtLastElement =
false;
14517 LeadingPointsAtLastElement =
true;
14526 OverallDistance += PrefDirElement.
Length23;
14527 if(OverallSpeedLimit != -1)
14537 OverallSpeedLimit = -1;
14544 OverallDistance += PrefDirElement.
Length01;
14545 if(OverallSpeedLimit != -1)
14555 OverallSpeedLimit = -1;
14574 int H, V, HLoc, VLoc, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
14577 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
14581 HLoc = MMIT->first.first;
14582 VLoc = MMIT->first.second;
14587 if(PrefDirPos0 > -1)
14591 if(PrefDirPos1 > -1)
14595 if(PrefDirPos2 > -1)
14599 if(PrefDirPos3 > -1)
14603 if(PrefDirPos3 > -1)
14606 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14608 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14610 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
14612 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement3.
GetRouteGraphicPtr(
false,
true));
14619 else if(PrefDirPos2 > -1)
14624 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14626 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14628 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
false));
14637 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14639 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
14641 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
14650 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14652 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
14654 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
14661 else if(PrefDirPos1 > -1)
14666 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14668 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14676 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
14678 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
14684 else if(PrefDirPos0 > -1)
14686 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
14703 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
14706 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
14728 if(PrefDirPos0 > -1)
14732 if(PrefDirPos1 > -1)
14736 if(PrefDirPos2 > -1)
14740 if(PrefDirPos3 > -1)
14744 if(PrefDirPos3 > -1)
14749 else if(PrefDirPos2 > -1)
14751 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos) || (PrefDirElement2.
XLinkPos == EntryPos))
14762 else if(PrefDirPos1 > -1)
14764 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos))
14775 else if(PrefDirPos0 > -1)
14777 if(PrefDirElement0.
XLinkPos == EntryPos)
14814 ElementIn.
VLoc +
"," + XLink);
14816 bool TrackFoundFlag;
14819 if((XLink == 2) || (XLink == 4) || (XLink == 6) || (XLink == 8))
14831 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
14841 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
14855 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
14865 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
14879 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
14889 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
14903 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
14913 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
14936 bool FoundFlag, ContFlag, FoundElements =
false;
14937 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
14942 LastIteratorValue++;
14968 if(PDVIt->XLinkPos == 0)
14973 StartElement = *PDVIt;
14982 int NextTrackVectorPosition = PDVIt->
Conn[PDVIt->GetXLinkPos()];
14984 Track->
TrackElementAt(879, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
14985 if(PrefDirPos0 == -1)
14989 bool NextElementFoundFlag =
false;
14993 NextElementFoundFlag =
true;
14995 if(PrefDirPos1 > -1)
15000 NextElementFoundFlag =
true;
15003 if(PrefDirPos2 > -1)
15008 NextElementFoundFlag =
true;
15011 if(PrefDirPos3 > -1)
15016 NextElementFoundFlag =
true;
15019 if(!NextElementFoundFlag)
15049 EndElement = NextElement;
15053 NextTrackVectorPosition = NextElement.
Conn[NextElement.
GetXLinkPos()];
15055 Track->
TrackElementAt(881, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
15056 if(PrefDirPos0 == -1)
15066 if(PrefDirPos1 > -1)
15074 if(PrefDirPos2 > -1)
15082 if(PrefDirPos3 > -1)
15113 FoundElements =
true;
15147 AnsiString(VLoc) +
"," + AnsiString((
short)AutoSigsFlag));
15149 int TrackVectorPosition;
15185 int LockedVectorNumber;
15208 bool InPrefDirFlag =
false;
15211 int PrefDirPos0 = -1;
15212 int PrefDirPos1 = -1;
15213 int PrefDirPos2 = -1;
15214 int PrefDirPos3 = -1;
15218 int PrefDirVecPos[4] =
15220 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
15223 for(
int x = 0; x < 4; x++)
15225 int b = PrefDirVecPos[x];
15235 InPrefDirFlag =
true;
15248 TrainController->
StopTTClockMessage(12,
"Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
15256 if(DummyPair.first > -1)
15258 throw Exception(
"Selection in two routes - should never happen!");
15260 if(RoutePair.first > -1)
15336 IDInt &ReqPosRouteID,
bool &PointsChanged)
15370 AnsiString(VLoc) +
"," + AnsiString((
short)ConsecSignals) +
"," + AnsiString((
short)AutoSigsFlag));
15372 int NewFailedPointsTVPos = -1;
15421 bool InPrefDirFlag =
false;
15424 int PrefDirPos0 = -1;
15425 int PrefDirPos1 = -1;
15426 int PrefDirPos2 = -1;
15427 int PrefDirPos3 = -1;
15430 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
15431 int PrefDirVecPos[4] =
15433 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
15436 for(
int x = 0; x < 4; x++)
15438 int b = PrefDirVecPos[x];
15441 InPrefDirFlag =
true;
15454 TrainController->
StopTTClockMessage(23,
"Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
15463 if(RoutePair.first > -1)
15465 if(RoutePair.second != 0)
15482 EndElement1 = RouteElement;
15483 EndElement2 = BlankElement;
15578 AutoSigsFlag,
false))
15583 if(NewFailedPointsTVPos > -1)
15587 " failed during route setting.");
15591 PointsChanged =
true;
15614 AutoSigsFlag,
false))
15619 if(NewFailedPointsTVPos > -1)
15623 " failed during route setting.");
15627 PointsChanged =
true;
15645 AutoSigsFlag,
false))
15650 if(NewFailedPointsTVPos > -1)
15654 " failed during route setting.");
15658 PointsChanged =
true;
15682 AutoSigsFlag,
false))
15687 if(NewFailedPointsTVPos > -1)
15691 " failed during route setting.");
15695 PointsChanged =
true;
15704 AutoSigsFlag,
false))
15709 if(NewFailedPointsTVPos > -1)
15713 " failed during route setting.");
15717 PointsChanged =
true;
15728 AutoSigsFlag,
false))
15733 if(NewFailedPointsTVPos > -1)
15737 " failed during route setting.");
15741 PointsChanged =
true;
15747 AutoSigsFlag,
false))
15752 if(NewFailedPointsTVPos > -1)
15756 " failed during route setting.");
15760 PointsChanged =
true;
15771 AutoSigsFlag,
false))
15776 if(NewFailedPointsTVPos > -1)
15780 " failed during route setting.");
15784 PointsChanged =
true;
15838 TOnePrefDir *EveryPrefDir,
bool ConsecSignals,
int EndPosition,
bool AutoSigsFlag,
bool RecursiveCall)
15890 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString(
ReqPosRouteID.
GetInt()) +
"," + AnsiString(EndPosition) +
"," +
15891 AnsiString((
short)AutoSigsFlag) +
"," + AnsiString((
short)RecursiveCall));
15892 int VectorCount = 0;
15901 if((PrefDirElement.
XLink == 1) || (PrefDirElement.
XLink == 3) || (PrefDirElement.
XLink == 7) || (PrefDirElement.
XLink == 9))
15905 for(
int x = 0; x < VectorCount; x++)
15913 bool FirstPass =
true;
15923 for(
int x = 0; x < VectorCount; x++)
15932 for(
int x = 0; x < VectorCount; x++)
15944 for(
int x = 0; x < VectorCount; x++)
15952 int NextPosition = PrefDirElement.
Conn[XLinkPos];
15956 int NextELinkPos = PrefDirElement.
ConnLinkPos[XLinkPos];
15957 SearchElement.
ELinkPos = NextELinkPos;
15958 SearchElement.
ELink = SearchElement.
Link[NextELinkPos];
15979 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
15981 SearchElement.
XLinkPos = NextXLinkPos;
15999 for(
int x = 0; x < VectorCount; x++)
16015 for(
int x = 0; x < VectorCount; x++)
16029 if(RoutePair.first > -1)
16038 for(
int x = 0; x < VectorCount; x++)
16047 if(SecondPair.first > -1)
16056 for(
int x = 0; x < VectorCount; x++)
16070 for(
int x = 0; x < VectorCount; x++)
16081 for(
int x = 0; x < VectorCount; x++)
16090 for(
int x = 0; x < VectorCount; x++)
16099 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
16103 for(
int x = 0; x < VectorCount; x++)
16113 bool InPrefDirFlag =
false;
16114 PrefDirElement1 = BlankElement;
16115 PrefDirElement2 = BlankElement;
16118 int PrefDirPos0 = -1;
16119 int PrefDirPos1 = -1;
16120 int PrefDirPos2 = -1;
16121 int PrefDirPos3 = -1;
16124 int PrefDirVecPos[4] =
16126 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
16128 for(
int x = 0; x < 4; x++)
16130 int b = PrefDirVecPos[x];
16133 InPrefDirFlag =
true;
16146 for(
int x = 0; x < VectorCount; x++)
16158 for(
int x = 0; x < VectorCount; x++)
16174 for(
int x = 0; x < VectorCount; x++)
16185 for(
int x = 0; x < VectorCount; x++)
16205 for(
int x = 0; x < VectorCount; x++)
16218 for(
int x = 0; x < VectorCount; x++)
16232 for(
int x = 0; x < VectorCount; x++)
16242 for(
int x = 0; x < VectorCount; x++)
16273 for(
int x = 0; x < VectorCount; x++)
16282 for(
int x = 0; x < VectorCount; x++)
16294 int SearchPos1 = SearchElement.
Attribute + 1;
16296 if(SearchPos1 == 2)
16300 if(SearchPos1 == 1)
16308 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
16309 SearchElement.
XLinkPos = SearchPos1;
16310 InPrefDirFlag =
false;
16311 if(SearchElement.
XLink == PrefDirElement1.
XLink)
16313 SearchElement = PrefDirElement1;
16314 InPrefDirFlag =
true;
16316 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
16318 SearchElement = PrefDirElement2;
16319 InPrefDirFlag =
true;
16325 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
16329 for(
int x = 0; x < VectorCount; x++)
16347 AutoSigsFlag,
true))
16356 for(
int x = 0; x < VectorCount; x++)
16365 for(
int x = 0; x < VectorCount; x++)
16385 for(
int x = 0; x < VectorCount; x++)
16395 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
16396 SearchElement.
XLinkPos = SearchPos2;
16397 if(SearchElement.
XLink == PrefDirElement1.
XLink)
16399 SearchElement = PrefDirElement1;
16401 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
16403 SearchElement = PrefDirElement2;
16407 for(
int x = 0; x < VectorCount; x++)
16415 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
16419 for(
int x = 0; x < VectorCount; x++)
16438 AutoSigsFlag,
true))
16447 for(
int x = 0; x < VectorCount; x++)
16456 for(
int x = 0; x < VectorCount; x++)
16468 for(
int x = 0; x < VectorCount; x++)
16478 SearchElement = PrefDirElement1;
16487 XLinkPos = SearchElement.
XLinkPos;
16488 PrefDirElement = SearchElement;
16545 unsigned int TruncatePrefDirPosition = 0;
16618 throw Exception(
"Error - failed to validate extended route for preferred route");
16673 throw Exception(
"Error - failed to validate single route for preferred route");
16718 AnsiString(VLoc) +
"," + AnsiString((
short)Callon));
16720 int TrackVectorPosition;
16757 int LockedVectorNumber;
16791 PrefDirElement1.
ELink = PrefDirElement1.
Link[0];
16792 PrefDirElement1.
XLink = PrefDirElement1.
Link[1];
16795 throw Exception(
"Error, No EXNumber for PrefDirElement1 in GetNonPreferredRouteStartElement");
16801 PrefDirElement2.
ELink = PrefDirElement2.
Link[1];
16802 PrefDirElement2.
XLink = PrefDirElement2.
Link[0];
16805 throw Exception(
"Error, No EXNumber for PrefDirElement2 in GetNonPreferredRouteStartElement");
16819 if(RoutePair.first > -1)
16954 int NewFailedPointsTVPos = -1;
17019 EndElement1.
ELink = EndElement1.
Link[0];
17020 EndElement1.
XLink = EndElement1.
Link[1];
17023 throw Exception(
"Error, No EXNumber for EndElement1 in GetNonPreferredRouteStartElement");
17028 EndElement2.
ELink = EndElement2.
Link[1];
17029 EndElement2.
XLink = EndElement2.
Link[0];
17032 throw Exception(
"Error, No EXNumber for EndElement2 in GetNonPreferredRouteStartElement");
17076 if(RoutePair.first > -1)
17078 if(RoutePair.second != 0)
17101 EndElement2 = BlankElement;
17186 if(NewFailedPointsTVPos > -1)
17190 " failed during route setting.");
17194 PointsChanged =
true;
17220 if(NewFailedPointsTVPos > -1)
17224 " failed during route setting.");
17228 PointsChanged =
true;
17250 if(NewFailedPointsTVPos > -1)
17254 " failed during route setting.");
17258 PointsChanged =
true;
17284 if(NewFailedPointsTVPos > -1)
17288 " failed during route setting.");
17292 PointsChanged =
true;
17306 if(NewFailedPointsTVPos > -1)
17310 " failed during route setting.");
17314 PointsChanged =
true;
17354 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString() +
"," + AnsiString(
ReqPosRouteID.
GetInt()));
17355 int VectorCount = 0;
17358 if((CurrentTrackElement.
Link[XLinkPos] == 1) || (CurrentTrackElement.
Link[XLinkPos] == 3) || (CurrentTrackElement.
Link[XLinkPos] == 7) ||
17359 (CurrentTrackElement.
Link[XLinkPos] == 9))
17363 for(
int x = 0; x < VectorCount; x++)
17375 for(
int x = 0; x < VectorCount; x++)
17382 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
17384 for(
int x = 0; x < VectorCount; x++)
17391 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
17395 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
17396 SearchElement.
ELinkPos = NextELinkPos;
17417 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
17419 SearchElement.
XLinkPos = NextXLinkPos;
17437 for(
int x = 0; x < VectorCount; x++)
17453 for(
int x = 0; x < VectorCount; x++)
17467 if(RoutePair.first > -1)
17476 for(
int x = 0; x < VectorCount; x++)
17485 if(SecondPair.first > -1)
17494 for(
int x = 0; x < VectorCount; x++)
17508 for(
int x = 0; x < VectorCount; x++)
17519 for(
int x = 0; x < VectorCount; x++)
17528 for(
int x = 0; x < VectorCount; x++)
17537 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
17541 for(
int x = 0; x < VectorCount; x++)
17554 for(
int x = 0; x < VectorCount; x++)
17582 for(
int x = 0; x < VectorCount; x++)
17595 for(
int x = 0; x < VectorCount; x++)
17605 for(
int x = 0; x < VectorCount; x++)
17630 for(
int x = 0; x < VectorCount; x++)
17639 for(
int x = 0; x < VectorCount; x++)
17652 int SearchPos1 = SearchElement.
Attribute + 1;
17654 if(SearchPos1 == 2)
17658 if(SearchPos1 == 1)
17667 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
17668 SearchElement.
XLinkPos = SearchPos1;
17670 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
17674 for(
int x = 0; x < VectorCount; x++)
17692 for(
int x = 0; x < VectorCount; x++)
17708 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
17709 SearchElement.
XLinkPos = SearchPos2;
17711 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
17715 for(
int x = 0; x < VectorCount; x++)
17731 for(
int x = 0; x < VectorCount; x++)
17743 for(
int x = 0; x < VectorCount; x++)
17758 CurrentTrackElement = SearchElement;
17759 XLinkPos = SearchElement.
XLinkPos;
17781 throw Exception(
"Error, SearchVector empty");
17793 for(
int x = 0; x < 4; x++)
17835 throw Exception(
"Error in EntryExitNumber 3");
17890 unsigned int TruncatePrefDirPosition = 0;
17950 throw Exception(
"Failed to validate extended route for nonpreferred route");
17995 throw Exception(
"Failed to validate single route for nonpreferred route");
18015 if(!PrefDirVector.empty())
18019 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 1) || (PrefDirPtr->XLinkPos == 1)))
18024 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 3) || (PrefDirPtr->XLinkPos == 3)))
18041 if(!PrefDirVector.empty())
18046 GetFixedPrefDirElementAt(193, 0).XLinkPos, RouteNumber);
18063 NewFailedPointsTVPos = -1;
18064 bool PointsChanged =
false;
18072 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 1) || (SearchPtr->XLinkPos == 1)))
18082 NewFailedPointsTVPos = SearchPtr->TrackVectorPosition;
18083 IFE.
TVPos = NewFailedPointsTVPos;
18102 PointsChanged =
true;
18105 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 3) || (SearchPtr->XLinkPos == 3)))
18115 NewFailedPointsTVPos = SearchPtr->TrackVectorPosition;
18116 IFE.
TVPos = NewFailedPointsTVPos;
18135 PointsChanged =
true;
18141 return(PointsChanged);
18165 NextForwardLinkedRouteNumber = -1;
18166 for(
unsigned int x = StartPos; x < PrefDirSize(); x++)
18168 int TrainID =
Track->
TrackElementAt(100, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnElement;
18169 if(PrefDirVector.at(x).TrackType ==
Bridge)
18171 if(PrefDirVector.at(x).XLinkPos < 2)
18173 TrainID =
Track->
TrackElementAt(101, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeOrFailedPointOrigSpeedLimit01;
18177 TrainID =
Track->
TrackElementAt(102, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeOrFailedPointOrigSpeedLimit23;
18185 if(PrefDirVector.at(x).TrackType ==
Buffers)
18197 if(
Track->
IsLCAtHV(42, PrefDirVector.at(x).HLoc, PrefDirVector.at(x).VLoc))
18206 if(PrefDirVector.at(x).Config[PrefDirVector.at(x).XLinkPos] ==
Signal)
18208 Attribute =
Track->
TrackElementAt(103, PrefDirVector.at(x).TrackVectorPosition).Attribute;
18220 if(x == PrefDirSize() - 1)
18223 NextForwardLinkedRouteNumber = -1;
18271 AnsiString(PrefDirVectorStartPosition));
18277 if(!PrefDirVector.empty())
18279 if(!SkipForwardLook)
18281 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr < PrefDirVector.end(); PrefDirPtr++)
18284 if(PrefDirPtr->TrackType ==
Bridge)
18286 if(PrefDirPtr->XLinkPos < 2)
18297 SkipForwardLook =
true;
18305 SkipForwardLook =
true;
18308 int NextForwardLinkedRouteNumber = -1;
18309 if((
unsigned int)PrefDirVectorStartPosition == PrefDirSize() - 1)
18311 TPrefDirElement PDE = GetFixedPrefDirElementAt(267, PrefDirVectorStartPosition);
18316 SkipForwardLook =
true;
18317 if(PrefDirVector.back().TrackType ==
Buffers)
18323 bool SetAttributeTo3 =
true;
18334 SetAttributeTo3 =
false;
18335 Attribute = AutoSigVectorIT->AccessNumber;
18341 if(SetAttributeTo3)
18352 SkipForwardLook =
true;
18353 if(PrefDirVector.back().TrackType ==
Buffers)
18366 if(!SkipForwardLook)
18371 if((
unsigned int)PrefDirVectorStartPosition < (PrefDirSize() - 1))
18373 StartPos = PrefDirVectorStartPosition + 1;
18381 if(!FindForwardTargetSignalAttribute(2, NextForwardLinkedRouteNumber, Attribute, StartPos))
18400 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr >= PrefDirVector.begin(); PrefDirPtr--)
18403 if(PrefDirPtr->TrackType ==
Bridge)
18405 if(PrefDirPtr->XLinkPos < 2)
18421 if(
Track->
IsLCAtHV(20, PrefDirPtr->HLoc, PrefDirPtr->VLoc))
18430 if(PrefDirPtr->Config[PrefDirPtr->XLinkPos] ==
Signal)
18433 PrefDirPtr->PrefDirRoute)
18437 int LockedVecNum = 0;
18439 bool KeepAttributeAt0ForLockedRoute =
false;
18444 KeepAttributeAt0ForLockedRoute =
true;
18449 bool NotGroundSignal =
false;
18452 NotGroundSignal =
true;
18477 if((Attribute < 3) && !KeepAttributeAt0ForLockedRoute && (NotGroundSignal || (Attribute == 0)))
18506 "," + AnsiString((
short)PrefDirRoute));
18507 bool ElementInRoute =
false;
18508 bool MovingTrainOccupyingRoute =
false;
18509 unsigned int TruncatePDElementPos;
18510 enum {NoTruncate, BackTruncate, FrontTruncate, FullTruncate} TruncateType;
18511 TruncateType = NoTruncate;
18518 TruncatePDElementPos = b;
18519 ElementInRoute =
true;
18523 if(!ElementInRoute)
18533 if(TruncatePDElementPos == 0)
18535 TruncateType = FullTruncate;
18543 TruncateType = FrontTruncate;
18547 TruncateType = BackTruncate;
18554 TruncateType = BackTruncate;
18560 if(TruncateType == BackTruncate)
18580 MovingTrainOccupyingRoute =
true;
18591 if(b ==
int(TruncatePDElementPos))
18597 else if(TruncateType == FrontTruncate)
18617 MovingTrainOccupyingRoute =
true;
18628 if(b == TruncatePDElementPos)
18654 MovingTrainOccupyingRoute =
true;
18676 if(((TruncatePDElementPos == 1) && (TruncateType == BackTruncate)) || ((TruncatePDElementPos == (
PrefDirSize() - 2)) && (TruncateType == FrontTruncate)))
18685 if((TruncatePDElementPos > 0) && (TruncateType == BackTruncate))
18692 TrainController->
StopTTClockMessage(145,
"Invalid green or blue route truncation position:\n\nto truncate from the start of the route select a position immediately before a facing signal "
18693 "that lies within the route;\n\nto truncate to the end of the route select a position immediately after a facing signal "
18694 "that lies within the route;\n\nor to remove the whole route select the first track element in the route");
18714 else if((TruncatePDElementPos < (
PrefDirSize() - 1)) && (TruncateType == FrontTruncate))
18721 TrainController->
StopTTClockMessage(146,
"Invalid green or blue route truncation position:\n\nto truncate from the start of the route select a position immediately before a facing signal "
18722 "that lies within the route;\n\nto truncate to the end of the route select a position immediately after a facing signal "
18723 "that lies within the route;\n\nor to remove the whole route select the first track element in the route");
18732 if(TruncatePDElementPos > 0)
18747 else if(TruncatePDElementPos == 0)
18754 TrainController->
StopTTClockMessage(148,
"Invalid green or blue route truncation position:\n\nto truncate from the start of the route select a position immediately before a facing signal "
18755 "that lies within the route;\n\nto truncate to the end of the route select a position immediately after a facing signal "
18756 "that lies within the route;\n\nor to remove the whole route select the first track element in the route");
18776 int ThisRouteNumber;
18786 if(LRVIT->RouteNumber == ThisRouteNumber)
18797 unsigned int LookBackwardsFromHere = 0;
18798 if(TruncateType == BackTruncate)
18800 LookBackwardsFromHere = TruncatePDElementPos;
18812 int button = Application->MessageBox(L
"Moving train approaching or occupying route, YES to lock route (2 minutes to release), NO to cancel",
18813 L
"Warning!", MB_YESNO | MB_ICONWARNING);
18826 bool ExistingLockedRouteModified =
false;
18828 if(TruncateType == BackTruncate)
18834 else if(TruncateType == FrontTruncate)
18855 if(LRVIT->RouteNumber == ThisRouteNumber)
18859 ExistingLockedRouteModified =
true;
18863 if(!ExistingLockedRouteModified)
18867 if(TruncateType == BackTruncate)
18870 RearPosition = TruncatePDElementPos;
18873 else if(TruncateType == FrontTruncate)
18877 FrontPosition = TruncatePDElementPos;
18886 for(
int c = FrontPosition; c >= RearPosition; c--)
18904 if(TruncateType == BackTruncate)
18906 RearPosition = TruncatePDElementPos;
18910 else if(TruncateType == FrontTruncate)
18913 FrontPosition = TruncatePDElementPos;
18930 for(
int c = FrontPosition; c >= RearPosition; c--)
18974 TPrefDirElement NewGreenFirstPDElement, NewRedFirstPDElement, NewGreenLastPDElement, NewRedLastPDElement;
18987 if(RouteColour == 1)
18989 NewRedFirstPDElement = LastPDElement;
18993 NewRedFirstPDElement.
IsARoute =
true;
18999 if(R2MMIt->second.first ==
int(x))
19001 R2MMIt->second.second++;
19008 else if(RouteColour == 2)
19010 NewGreenFirstPDElement = LastPDElement;
19014 NewGreenFirstPDElement.
IsARoute =
true;
19020 if(R2MMIt->second.first ==
int(x))
19022 R2MMIt->second.second++;
19045 if(RouteColour == 1)
19047 NewRedLastPDElement = FirstPDElement;
19056 else if(RouteColour == 2)
19058 NewGreenLastPDElement = FirstPDElement;
19127 ARVIt->SetRouteSignals(14);
19146 AnsiString((
short)PrefDirRoute));
19171 AnsiString((
short)PrefDirRoute));
19181 RouteFlashElement.
HLoc = H;
19182 RouteFlashElement.
VLoc = V;
19198 int H = PrefDirPtr->HLoc;
19199 int V = PrefDirPtr->VLoc;
19266 for(
unsigned int x = 0; x < RouteFlashVector.size(); x++)
19272 Display->
PlotOutput(21, RouteFlashVector.at(x).HLoc * 16, RouteFlashVector.at(x).VLoc * 16, RouteFlashVector.at(x).OriginalGraphic);
19275 OverlayPlotted =
false;
19298 bool FirstSignalFound =
false;
19305 if(PDVIt->TrackType ==
Points)
19307 if((PDVIt->ELinkPos == 1) || (PDVIt->XLinkPos == 1))
19318 else if((PDVIt->ELinkPos == 3) || (PDVIt->XLinkPos == 3))
19333 int XLinkPosition = PDVIt->XLinkPos;
19334 if(PDVIt->XLinkPos == -1)
19338 for(
int x = 0; x < 4; x++)
19340 if(PDVIt->Conn[x] == (PDVIt + 1)->TrackVectorPosition)
19353 if(XLinkPosition > -1)
19355 if(!FirstSignalFound && (PDVIt->Config[XLinkPosition] ==
Signal))
19357 FirstSignalFound =
true;
19360 else if(FirstSignalFound && (PDVIt->Config[XLinkPosition] ==
Signal))
19371 IFE.
TVPos = PDVIt->TrackVectorPosition;
19377 " failed when changing aspect.\nTrains can only pass under signaller control.");
19407 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
19409 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedRouteAt");
19412 return(AllRoutesVector.at(At));
19420 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
19422 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableRouteAt");
19425 return(AllRoutesVector.at(At));
19436 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
19438 GetFixedRouteAt(62, a).PrefDirMarker(7,
RouteCall,
false, Disp);
19448 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
19450 GetFixedRouteAt(166, a).RouteImageMarker(0, Bitmap);
19468 AnsiString(VLoc) +
"," + AnsiString((
short)PrefDirRoute));
19469 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
19473 GetModifiableRouteAt(7, a).TruncateRoute(0, HLoc, VLoc, PrefDirRoute, ReturnFlag);
19502 AnsiString(LinkPos));
19503 if(TrackVectorPosition == -1)
19508 THVPair Route2MultiMapKeyPair;
19512 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
19515 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
19525 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
19527 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
19530 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(64, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(88,
19531 Route2MultiMapIterator->second.second);
19532 EntryLinkPos = PrefDirElement1.
ELinkPos;
19533 ExitLinkPos = PrefDirElement1.
XLinkPos;
19534 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
19535 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
19547 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
19559 Graphics::TBitmap* &EntryDirectionGraphicPtr)
19569 AnsiString(LinkPos));
19572 if(TrackVectorPosition == -1)
19577 THVPair Route2MultiMapKeyPair;
19581 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
19584 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
19589 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
19591 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
19593 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(73, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(97,
19594 Route2MultiMapIterator->second.second);
19595 EntryLinkPos = PrefDirElement1.
ELinkPos;
19596 ExitLinkPos = PrefDirElement1.
XLinkPos;
19597 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
19598 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
19602 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(74,
19603 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
19610 return(AutoSigsRoute);
19615 return(NotAutoSigsRoute);
19621 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(75,
19622 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
19629 return(AutoSigsRoute);
19634 return(NotAutoSigsRoute);
19638 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
19640 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
19641 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
19643 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(76, ItPair.first->second.first).GetFixedPrefDirElementAt(98, ItPair.first->second.second);
19644 EntryLinkPos = PrefDirElement2.
ELinkPos;
19645 ExitLinkPos = PrefDirElement2.
XLinkPos;
19646 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
19647 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
19651 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(77, ItPair.first->second.first).PrefDirSize() - 1))
19658 return(AutoSigsRoute);
19663 return(NotAutoSigsRoute);
19669 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(78, ItPair.first->second.first).PrefDirSize() - 1))
19676 return(AutoSigsRoute);
19681 return(NotAutoSigsRoute);
19685 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(79, ItPair.second->second.first).GetFixedPrefDirElementAt(99, ItPair.second->second.second);
19686 EntryLinkPos = PrefDirElement3.
ELinkPos;
19687 ExitLinkPos = PrefDirElement3.
XLinkPos;
19688 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
19689 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
19693 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(80, ItPair.second->second.first).PrefDirSize() - 1))
19700 return(AutoSigsRoute);
19705 return(NotAutoSigsRoute);
19711 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(81, ItPair.second->second.first).PrefDirSize() - 1))
19718 return(AutoSigsRoute);
19723 return(NotAutoSigsRoute);
19739 AnsiString(LinkPos));
19740 if(TrackVectorPosition == -1)
19746 THVPair Route2MultiMapKeyPair;
19750 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
19753 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
19759 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
19761 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
19763 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(82, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(100,
19764 Route2MultiMapIterator->second.second);
19765 EntryLinkPos = PrefDirElement1.
ELinkPos;
19766 ExitLinkPos = PrefDirElement1.
XLinkPos;
19767 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
19768 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
19771 RouteNumber = Route2MultiMapIterator->second.first;
19775 return(AutoSigsRoute);
19780 return(NotAutoSigsRoute);
19785 RouteNumber = Route2MultiMapIterator->second.first;
19789 return(AutoSigsRoute);
19794 return(NotAutoSigsRoute);
19798 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
19800 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
19801 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
19803 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(83, ItPair.first->second.first).GetFixedPrefDirElementAt(101, ItPair.first->second.second);
19804 EntryLinkPos = PrefDirElement2.
ELinkPos;
19805 ExitLinkPos = PrefDirElement2.
XLinkPos;
19806 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
19807 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
19810 RouteNumber = ItPair.first->second.first;
19814 return(AutoSigsRoute);
19819 return(NotAutoSigsRoute);
19824 RouteNumber = ItPair.first->second.first;
19828 return(AutoSigsRoute);
19833 return(NotAutoSigsRoute);
19837 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(84, ItPair.second->second.first).GetFixedPrefDirElementAt(102, ItPair.second->second.second);
19838 EntryLinkPos = PrefDirElement3.
ELinkPos;
19839 ExitLinkPos = PrefDirElement3.
XLinkPos;
19840 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
19841 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
19844 RouteNumber = ItPair.second->second.first;
19848 return(AutoSigsRoute);
19853 return(NotAutoSigsRoute);
19858 RouteNumber = ItPair.second->second.first;
19862 return(AutoSigsRoute);
19867 return(NotAutoSigsRoute);
19889 EmptyRoute.
RouteID = NextRouteID;
19892 AllRoutesVector.push_back(EmptyRoute);
19893 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
19918 AllRoutesVector.push_back(EmptyRoute);
19919 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
19942 THVPair Route2MultiMapKeyPair;
19951 LockedRouteRearTrackVectorPosition = 0;
19952 LockedRouteLastTrackVectorPosition = 0;
19953 LockedRouteLastXLinkPos = 0;
19954 LockedRouteLockStartTime = TDateTime(0);
19955 if(!LockedRouteVector.empty())
19959 if(LRVIT->RouteNumber == RouteNumber)
19961 LockedRouteRearTrackVectorPosition = LRVIT->RearTrackVectorPosition;
19962 LockedRouteLastTrackVectorPosition = LRVIT->LastTrackVectorPosition;
19963 LockedRouteLastXLinkPos = LRVIT->LastXLinkPos;
19964 LockedRouteLockStartTime = LRVIT->LockStartTime;
19965 LockedRouteFoundDuringRouteBuilding =
true;
19966 LockedRouteVector.erase(LRVIT);
19991 AnsiString(VLoc) +
"," + AnsiString(ELink));
19994 ReturnPair.first = -1;
19995 ReturnPair.second = 0;
19996 THVPair Route2MultiMapKeyPair;
19998 Route2MultiMapKeyPair.first = HLoc;
19999 Route2MultiMapKeyPair.second = VLoc;
20002 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
20003 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
20005 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
20006 Route2MultiMapIterator = ItPair.first;
20008 if(ItPair.first == ItPair.second)
20010 throw Exception(
"Failed to find Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc);
20012 if(GetFixedRouteAt(111, ItPair.first->second.first).GetFixedPrefDirElementAt(132, ItPair.first->second.second).GetELink() == ELink)
20014 ReturnPair.first = ItPair.first->second.first;
20015 ReturnPair.second = ItPair.first->second.second;
20016 Route2MultiMapIterator = ItPair.first;
20018 return(ReturnPair);
20021 if(ItPair.first == ItPair.second)
20023 throw Exception(
"Found Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc +
" but failed to find required element");
20025 if(GetFixedRouteAt(112, ItPair.first->second.first).GetFixedPrefDirElementAt(133, ItPair.first->second.second).GetELink() == ELink)
20027 ReturnPair.first = ItPair.first->second.first;
20028 ReturnPair.second = ItPair.first->second.second;
20029 Route2MultiMapIterator = ItPair.first;
20031 return(ReturnPair);
20034 return(ReturnPair);
20049 AnsiString(VLoc) +
"," + AnsiString(ELink));
20050 THVPair Route2MultiMapKeyPair;
20052 Route2MultiMapKeyPair.first = HLoc;
20053 Route2MultiMapKeyPair.second = VLoc;
20054 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
20056 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
20058 if(ItPair.first == ItPair.second)
20064 if(GetFixedRouteAt(205, ItPair.first->second.first).GetFixedPrefDirElementAt(241, ItPair.first->second.second).GetELink() == ELink)
20066 RouteNumber = ItPair.first->second.first;
20072 if(ItPair.first == ItPair.second)
20078 if(GetFixedRouteAt(206, ItPair.first->second.first).GetFixedPrefDirElementAt(242, ItPair.first->second.second).GetELink() == ELink)
20080 RouteNumber = ItPair.first->second.first;
20101 "," + AnsiString(ELinkIn) +
"," + AnsiString(RouteNumber) +
"," + AnsiString(RouteElementNumber));
20102 THVPair Route2MultiMapKeyPair;
20104 Route2MultiMapKeyPair.first = HLoc;
20105 Route2MultiMapKeyPair.second = VLoc;
20108 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
20111 RouteElementPair.first = RouteNumber;
20112 RouteElementPair.second = RouteElementNumber;
20113 Route2MultiMapEntry.second = RouteElementPair;
20115 if(Route2MultiMap.find(Route2MultiMapKeyPair) != Route2MultiMap.end())
20118 if(GetFixedRouteAt(113, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(134,
20119 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).GetELink() != ELinkIn)
20122 if(GetFixedRouteAt(114, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(135,
20123 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).TrackType !=
Bridge)
20125 throw Exception(
"Error, bridge expected in Route2MultiMapInsert but not, at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
20127 Route2MultiMap.insert(Route2MultiMapEntry);
20132 throw Exception(
"Error, route map entry found in Route2MultiMapInsert at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
20137 Route2MultiMap.insert(Route2MultiMapEntry);
20155 TempPair.first = -1;
20156 TempPair.second = 0;
20157 SecondPair = TempPair;
20159 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItRange;
20160 THVPair Route2MultiMapKeyPair;
20162 Route2MultiMapKeyPair.first = HLoc;
20163 Route2MultiMapKeyPair.second = VLoc;
20164 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
20169 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
20171 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
20173 return(Route2MultiMapIterator->second);
20175 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
20177 ItRange = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
20178 TempPair = ItRange.first->second;
20179 SecondPair = (--ItRange.second)->second;
20202 TRouteElementPair RouteElementPair = GetRouteElementDataFromRoute2MultiMap(8, CheckElement.
HLoc, CheckElement.
VLoc, SecondPair);
20203 if(RouteElementPair.first == -1)
20206 throw Exception(
"CheckMapAndRoutes Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
20207 " in Route2MultiMap, Caller=" + (AnsiString)Caller);
20209 if((RouteElementPair.first != (
int)a) && (SecondPair.first != (
int)a))
20212 throw Exception(
"CheckMapAndRoutes Error - RouteNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
20213 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)RouteElementPair.first +
" Route value=" + (AnsiString)a +
" Caller=" +
20214 (AnsiString)Caller);
20216 if(((RouteElementPair.first != (
int)a) || (RouteElementPair.second != b)) && ((SecondPair.first != (
int)a) || (SecondPair.second != b)))
20219 throw Exception(
"CheckMapAndRoutes Error - PrefDirVectorNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
20220 (AnsiString)CheckElement.
VLoc +
" 1st Map value RouteNum/ElementNum =" + (AnsiString)RouteElementPair.first +
"/" +
20221 (AnsiString)RouteElementPair.second +
" 2nd Map value =" + (AnsiString)SecondPair.first +
"/" + (AnsiString)SecondPair.second +
20222 " Route value=" + (AnsiString)a +
"/" + (AnsiString)b +
" Caller=" + (AnsiString)Caller);
20226 unsigned int SizeVal = 0;
20229 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
20231 SizeVal += GetFixedRouteAt(117, a).PrefDirSize();
20233 if(SizeVal != Route2MultiMap.size())
20235 throw Exception(
"CheckMapAndRoutes Error - Map Size=" + (AnsiString)Route2MultiMap.size() +
" RouteSize=" + (AnsiString)SizeVal +
" Caller=" +
20236 (AnsiString)Caller);
20252 if(!Route2MultiMap.empty())
20254 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
20256 if(Route2MultiMapIterator->second.first > RouteNumber)
20258 Route2MultiMapIterator->second.first--;
20275 AnsiString(RouteNumber) +
"," + AnsiString(ErasedElementNumber));
20276 if(!Route2MultiMap.empty())
20278 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
20280 if((Route2MultiMapIterator->second.first == RouteNumber) && (Route2MultiMapIterator->second.second > ErasedElementNumber))
20282 Route2MultiMapIterator->second.second--;
20301 AnsiString(ELink));
20305 RequiredRoutePair = FindRoutePairFromRoute2MultiMap(0, HLoc, VLoc, ELink, Route2MultiMapIterator);
20306 if(RequiredRoutePair.first == -1)
20308 throw Exception(
"Failed to find route element in RemoveRouteElement");
20310 Route2MultiMap.erase(Route2MultiMapIterator);
20311 DecrementRouteElementNumbersInRoute2MultiMap(0, RequiredRoutePair.first, RequiredRoutePair.second);
20314 TPrefDirElement LockedRouteElement, PrefDirElement = GetFixedRouteAt(118, RequiredRoutePair.first).GetFixedPrefDirElementAt(137, RequiredRoutePair.second);
20335 GetModifiableRouteAt(8, RequiredRoutePair.first).PrefDirVector.erase(GetModifiableRouteAt(33, RequiredRoutePair.first).PrefDirVector.begin() + RequiredRoutePair.second);
20346 if(AutoSigVectorIT->RouteNumber == RequiredRoutePair.first)
20354 if(GetModifiableRouteAt(10, RequiredRoutePair.first).PrefDirSize() == 0)
20356 TrainController->
LogEvent(
"RouteRemoved," + AnsiString(GetFixedRouteAt(189, RequiredRoutePair.first).RouteID));
20357 AllRoutesVector.erase(AllRoutesVector.begin() + RequiredRoutePair.first);
20358 DecrementRouteNumbersInRoute2MultiMap(0, RequiredRoutePair.first);
20370 if(!LockedRouteVector.empty())
20374 if(LRVIT->RouteNumber > RequiredRoutePair.first)
20376 LRVIT->RouteNumber--;
20386 if(AutoSigVectorIT->RouteNumber > RequiredRoutePair.first)
20388 AutoSigVectorIT->RouteNumber--;
20393 CheckMapAndRoutes(7);
20407 AnsiString(ELink) +
"," + AnsiString(RouteNumber) +
"," + RouteElement.
LogPrefDir());
20408 GetModifiableRouteAt(11, RouteNumber).StoreRouteElementInPrefDirVector(RouteElement);
20409 Route2MultiMapInsert(0, HLoc, VLoc, ELink, RouteNumber, GetModifiableRouteAt(12, RouteNumber).
PrefDirSize() - 1);
20426 "," + AnsiString(XLinkPos));
20430 RouteElementPair = GetRouteElementDataFromRoute2MultiMap(9, TE.
HLoc, TE.
VLoc, SecondPair);
20431 if(RouteElementPair.first == -1)
20433 throw Exception(
"Error, failed to find element in SetTrailingSignalsOnAutoSigsRoute - 1");
20435 TPrefDirElement RouteElement = GetFixedRouteAt(119, RouteElementPair.first).GetFixedPrefDirElementAt(138, RouteElementPair.second);
20437 RequiredPair = RouteElementPair;
20438 if(RouteElement.
XLinkPos != XLinkPos)
20440 if(SecondPair.first != -1)
20442 RouteElement = GetFixedRouteAt(120, SecondPair.first).GetFixedPrefDirElementAt(139, SecondPair.second);
20443 RequiredPair = SecondPair;
20444 if(RouteElement.
XLinkPos != XLinkPos)
20446 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 2");
20451 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 3");
20455 SetAllRearwardsSignals(5, 0, RequiredPair.first, RequiredPair.second);
20476 AnsiString(AccessNumber));
20478 int Attribute = AccessNumber;
20480 int x = GetFixedRouteAt(121, RouteNumber).PrefDirSize() - 1;
20484 throw Exception(
"Error - route not AutoSignals in SetTrailingSignalsOnContinuationRoute");
20488 throw Exception(
"Error - end element not continuation in SetTrailingSignalsOnContinuationRoute");
20491 x).XLinkPos] !=
End)
20493 throw Exception(
"Error - end element a continuation in SetTrailingSignalsOnContinuationRoute but End not facing right way");
20496 SetAllRearwardsSignals(6, Attribute, RouteNumber, GetFixedRouteAt(126, RouteNumber).
PrefDirSize() - 1);
20547 AnsiString(RouteNumber) +
"," + AnsiString(RouteStartPosition));
20548 TPrefDirElement FirstElement = GetFixedRouteAt(127, RouteNumber).GetFixedPrefDirElementAt(144, 0);
20549 int RearwardLinkedRouteNumber;
20552 bool SkipForwardLook =
false;
20561 SkipForwardLook =
true;
20563 RearwardLinkedRouteNumber).
PrefDirSize() - 1, SkipForwardLook)))
20573 int TrainID, TrainPosition, BehindTrainPosition;
20574 bool FoundTrain =
false, BehindTrain =
false;
20575 for(
int x = RouteStartPosition; x >= 0; x--)
20577 TPrefDirElement PrefDirElement = GetFixedRouteAt(132, RouteNumber).GetFixedPrefDirElementAt(146, x);
20602 if(FoundTrain && (TrainPosition > 1))
20606 for(
int x = TrainPosition; x >= 0; x--)
20610 TPrefDirElement PrefDirElement = GetFixedRouteAt(133, RouteNumber).GetFixedPrefDirElementAt(147, x);
20630 BehindTrain =
true;
20631 BehindTrainPosition = x;
20638 SetAllRearwardsSignals(7, 0, RouteNumber, BehindTrainPosition);
20655 AnsiString(LookBackwardsFromHere));
20656 int SignalCount = 0, TrainID, RearwardLinkedRouteNumber;
20657 TOneRoute CurrentRoute = GetFixedRouteAt(134, RouteNumber);
20660 bool ExamineRoute =
true;
20662 while(ExamineRoute)
20664 for(
int x = LookBackwardsFromHere; x >= 0; x--)
20709 if(SignalCount >= 3)
20724 LookBackwardsFromHere = CurrentRoute.
PrefDirSize() - 1;
20728 CurrentRoute = GetFixedRouteAt(135, RearwardLinkedRouteNumber);
20729 ExamineRoute =
true;
20730 LookBackwardsFromHere = GetFixedRouteAt(136, RearwardLinkedRouteNumber).PrefDirSize() - 1;
20765 ExamineRoute =
false;
20780 AnsiString(TrackVectorPosition) +
"," + AnsiString(XLinkPos));
20783 PrefDirElement = InternalPrefDirElement;
20784 if(LockedRouteVector.empty())
20791 bool InLockedRoute =
false;
20795 if(TrackIsInARoute(14, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos))
20799 InLockedRoute =
true;
20808 int RouteNumber, VectorCount = 0;
20813 RouteType = GetRouteTypeAndNumber(8, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos, RouteNumber);
20814 if(RouteType == NoRoute)
20827 for(
int x = GetFixedRouteAt(141, RouteNumber).
PrefDirSize() - 1; x >= 0; x--)
20829 InternalPrefDirElement = GetFixedRouteAt(142, RouteNumber).GetFixedPrefDirElementAt(152, x);
20834 PrefDirElement = InternalPrefDirElement;
20835 LockedVectorNumber = VectorCount;
20840 else if(InternalPrefDirElement.
TrackVectorPosition == (
int)LRVIT->RearTrackVectorPosition)
20844 PrefDirElement = InternalPrefDirElement;
20845 LockedVectorNumber = VectorCount;
20866 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20868 if(GetFixedRouteAt(157, x).RouteID ==
RouteID.GetInt())
20874 throw Exception(
"Error, failed to find RouteID in GetRouteVectorNumber for ID: " + AnsiString(
RouteID.GetInt()));
20884 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20886 if(GetFixedRouteAt(45, x).RouteID ==
RouteID.GetInt())
20901 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20903 if(GetFixedRouteAt(163, x).RouteID ==
RouteID.GetInt())
20906 return(GetFixedRouteAt(159, x));
20909 throw Exception(
"Error, failed to find RouteID in GetFixedRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
20917 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20919 if(GetFixedRouteAt(164, x).RouteID ==
RouteID.GetInt())
20922 return(GetModifiableRouteAt(15, x));
20925 throw Exception(
"Error, failed to find RouteID in GetModifiableRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
20935 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20937 TOneRoute OneRoute = GetFixedRouteAt(165, x);
20949 int NumberOfRoutes;
20953 for(
int x = 0; x < NumberOfRoutes; x++)
20960 StoreOneRouteAfterSessionLoad(0, &OneRoute);
20978 if((NumberOfRoutes < 0) || (NumberOfRoutes > 5000))
20985 if((NextID < 0) || (NextID > 1000000))
20990 for(
int x = 0; x < NumberOfRoutes; x++)
21015 AnsiString(StartPosition));
21016 if(EndPosition == StartPosition)
21022 int TVPos = EndPosition;
21023 int LkPos = EndXLinkPos;
21025 while(TrackIsInARoute(15, TVPos, LkPos))
21052 if(GetRouteTypeAndNumber(36, NewTVPos, NewLkPos, RouteNumber) == NoRoute)
21061 if((NewLkPos == 0) || (NewLkPos == 2))
21081 if(TVPos == StartPosition)
21113 AnsiString(VLoc) +
"," + AnsiString(DiagonalLinkNumber));
21118 if(FirstPair.first > -1)
21121 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
21126 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
21132 if(SecondPair.first > -1)
21135 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
21140 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
21146 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(0, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(1, HLoc - 1, VLoc,
21153 if(FirstPair.first > -1)
21156 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
21161 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
21167 if(SecondPair.first > -1)
21170 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
21175 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
21181 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(2, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(3, HLoc, VLoc - 1,
21188 if(FirstPair.first > -1)
21191 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
21196 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
21202 if(SecondPair.first > -1)
21205 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
21210 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
21216 if(((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(4, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(5, HLoc + 1, VLoc,
21223 if(FirstPair.first > -1)
21226 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
21231 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
21237 if(SecondPair.first > -1)
21240 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
21245 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
21251 if(((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(6, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(7, HLoc, VLoc + 1,
21275 "," + AnsiString(DiagonalLinkNumber));
21280 if(FirstPair.first > -1)
21283 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
21288 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
21294 if(SecondPair.first > -1)
21297 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
21302 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
21309 if(FirstPair.first > -1)
21312 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
21317 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
21323 if(SecondPair.first > -1)
21326 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
21331 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
21338 if(FirstPair.first > -1)
21341 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
21346 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
21352 if(SecondPair.first > -1)
21355 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
21360 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
21367 if(FirstPair.first > -1)
21370 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
21375 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
21381 if(SecondPair.first > -1)
21384 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
21389 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))